jupiter-dynamic-forms 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 +21 -0
- package/README.md +384 -0
- package/dist/core/concept-tree.d.ts +19 -0
- package/dist/core/concept-tree.d.ts.map +1 -0
- package/dist/core/dynamic-form.d.ts +42 -0
- package/dist/core/dynamic-form.d.ts.map +1 -0
- package/dist/core/form-field.d.ts +23 -0
- package/dist/core/form-field.d.ts.map +1 -0
- package/dist/core/form-section.d.ts +20 -0
- package/dist/core/form-section.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +784 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2082 -0
- package/dist/index.mjs.map +1 -0
- package/dist/schema/types.d.ts +151 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/xbrl-types.d.ts +142 -0
- package/dist/schema/xbrl-types.d.ts.map +1 -0
- package/dist/utils/validation.d.ts +29 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/xbrl-form-builder.d.ts +52 -0
- package/dist/utils/xbrl-form-builder.d.ts.map +1 -0
- package/package.json +91 -0
- package/wrappers/angular/jupiter-dynamic-forms.module.ts +30 -0
- package/wrappers/angular/public-api.ts +13 -0
- package/wrappers/angular/types.ts +33 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,784 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("lit"),t=e=>(t,r)=>{void 0!==r?r.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)},r=globalThis,i=r.ShadowRoot&&(void 0===r.ShadyCSS||r.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,o=Symbol(),s=new WeakMap;
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2017 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
*/let a=class{constructor(e,t,r){if(this._$cssResult$=!0,r!==o)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(i&&void 0===e){const r=void 0!==t&&1===t.length;r&&(e=s.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&s.set(t,e))}return e}toString(){return this.cssText}};const n=i?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const r of e.cssRules)t+=r.cssText;return(e=>new a("string"==typeof e?e:e+"",void 0,o))(t)})(e):e,{is:l,defineProperty:d,getOwnPropertyDescriptor:c,getOwnPropertyNames:p,getOwnPropertySymbols:h,getPrototypeOf:u}=Object,m=globalThis,b=m.trustedTypes,f=b?b.emptyScript:"",v=m.reactiveElementPolyfillSupport,y=(e,t)=>e,g={toAttribute(e,t){switch(t){case Boolean:e=e?f:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=null!==e;break;case Number:r=null===e?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch(i){r=null}}return r}},x=(e,t)=>!l(e,t),_={attribute:!0,type:String,converter:g,reflect:!1,useDefault:!1,hasChanged:x};
|
|
7
|
+
/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright 2017 Google LLC
|
|
10
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
+
*/Symbol.metadata??(Symbol.metadata=Symbol("metadata")),m.litPropertyMetadata??(m.litPropertyMetadata=new WeakMap);class $ extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=_){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const r=Symbol(),i=this.getPropertyDescriptor(e,r,t);void 0!==i&&d(this.prototype,e,i)}}static getPropertyDescriptor(e,t,r){const{get:i,set:o}=c(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:i,set(t){const s=null==i?void 0:i.call(this);null==o||o.call(this,t),this.requestUpdate(e,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??_}static _$Ei(){if(this.hasOwnProperty(y("elementProperties")))return;const e=u(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(y("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(y("properties"))){const e=this.properties,t=[...p(e),...h(e)];for(const r of t)this.createProperty(r,e[r])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,r]of t)this.elementProperties.set(e,r)}this._$Eh=new Map;for(const[t,r]of this.elementProperties){const e=this._$Eu(t,r);void 0!==e&&this._$Eh.set(e,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const e of r)t.unshift(n(e))}else void 0!==e&&t.push(n(e));return t}static _$Eu(e,t){const r=t.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof e?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),null==(e=this.constructor.l)||e.forEach(e=>e(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),void 0!==this.renderRoot&&this.isConnected&&(null==(t=e.hostConnected)||t.call(e))}removeController(e){var t;null==(t=this._$EO)||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const r of t.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{if(i)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const i of t){const t=document.createElement("style"),o=r.litNonce;void 0!==o&&t.setAttribute("nonce",o),t.textContent=i.cssText,e.appendChild(t)}})(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null==(e=this._$EO)||e.forEach(e=>{var t;return null==(t=e.hostConnected)?void 0:t.call(e)})}enableUpdating(e){}disconnectedCallback(){var e;null==(e=this._$EO)||e.forEach(e=>{var t;return null==(t=e.hostDisconnected)?void 0:t.call(e)})}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$ET(e,t){var r;const i=this.constructor.elementProperties.get(e),o=this.constructor._$Eu(e,i);if(void 0!==o&&!0===i.reflect){const s=(void 0!==(null==(r=i.converter)?void 0:r.toAttribute)?i.converter:g).toAttribute(t,i.type);this._$Em=e,null==s?this.removeAttribute(o):this.setAttribute(o,s),this._$Em=null}}_$AK(e,t){var r,i;const o=this.constructor,s=o._$Eh.get(e);if(void 0!==s&&this._$Em!==s){const e=o.getPropertyOptions(s),a="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null==(r=e.converter)?void 0:r.fromAttribute)?e.converter:g;this._$Em=s;const n=a.fromAttribute(t,e.type);this[s]=n??(null==(i=this._$Ej)?void 0:i.get(s))??n,this._$Em=null}}requestUpdate(e,t,r){var i;if(void 0!==e){const o=this.constructor,s=this[e];if(r??(r=o.getPropertyOptions(e)),!((r.hasChanged??x)(s,t)||r.useDefault&&r.reflect&&s===(null==(i=this._$Ej)?void 0:i.get(e))&&!this.hasAttribute(o._$Eu(e,r))))return;this.C(e,t,r)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:r,reflect:i,wrapped:o},s){r&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,s??t??this[e]),!0!==o||void 0!==s)||(this._$AL.has(e)||(this.hasUpdated||r||(t=void 0),this._$AL.set(e,t)),!0===i&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,r]of e){const{wrapped:e}=r,i=this[t];!0!==e||this._$AL.has(t)||void 0===i||this.C(t,void 0,r,i)}}let t=!1;const r=this._$AL;try{t=this.shouldUpdate(r),t?(this.willUpdate(r),null==(e=this._$EO)||e.forEach(e=>{var t;return null==(t=e.hostUpdate)?void 0:t.call(e)}),this.update(r)):this._$EM()}catch(i){throw t=!1,this._$EM(),i}t&&this._$AE(r)}willUpdate(e){}_$AE(e){var t;null==(t=this._$EO)||t.forEach(e=>{var t;return null==(t=e.hostUpdated)?void 0:t.call(e)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}updated(e){}firstUpdated(e){}}$.elementStyles=[],$.shadowRootOptions={mode:"open"},$[y("elementProperties")]=new Map,$[y("finalized")]=new Map,null==v||v({ReactiveElement:$}),(m.reactiveElementVersions??(m.reactiveElementVersions=[])).push("2.1.1");
|
|
12
|
+
/**
|
|
13
|
+
* @license
|
|
14
|
+
* Copyright 2017 Google LLC
|
|
15
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
+
*/
|
|
17
|
+
const w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:x},E=(e=w,t,r)=>{const{kind:i,metadata:o}=r;let s=globalThis.litPropertyMetadata.get(o);if(void 0===s&&globalThis.litPropertyMetadata.set(o,s=new Map),"setter"===i&&((e=Object.create(e)).wrapped=!0),s.set(r.name,e),"accessor"===i){const{name:i}=r;return{set(r){const o=t.get.call(this);t.set.call(this,r),this.requestUpdate(i,o,e)},init(t){return void 0!==t&&this.C(i,void 0,e,t),t}}}if("setter"===i){const{name:i}=r;return function(r){const o=this[i];t.call(this,r),this.requestUpdate(i,o,e)}}throw Error("Unsupported decorator location: "+i)};function S(e){return(t,r)=>"object"==typeof r?E(e,t,r):((e,t,r)=>{const i=t.hasOwnProperty(r);return t.constructor.createProperty(r,e),i?Object.getOwnPropertyDescriptor(t,r):void 0})(e,t,r)}
|
|
18
|
+
/**
|
|
19
|
+
* @license
|
|
20
|
+
* Copyright 2017 Google LLC
|
|
21
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
+
*/function j(e){return S({...e,state:!0,attribute:!1})}class F{static validateField(e,t,r,i,o,s=[]){const a=[];for(const n of s){const s=this.validateRule(e,t,r,i,o,n);s&&a.push(s)}return a}static validateRule(e,t,r,i,o,s){const a=null==i||""===i;switch(s.type){case"required":if(a)return this.createError(e,t,r,s);break;case"min":if(!a&&"number"==typeof i&&i<s.value)return this.createError(e,t,r,s);break;case"max":if(!a&&"number"==typeof i&&i>s.value)return this.createError(e,t,r,s);break;case"minLength":if(!a&&"string"==typeof i&&i.length<s.value)return this.createError(e,t,r,s);break;case"maxLength":if(!a&&"string"==typeof i&&i.length>s.value)return this.createError(e,t,r,s);break;case"pattern":if(!a&&"string"==typeof i){if(!new RegExp(s.value).test(i))return this.createError(e,t,r,s)}break;case"email":if(!a&&"string"==typeof i){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i))return this.createError(e,t,r,s)}break;case"url":if(!a&&"string"==typeof i)try{new URL(i)}catch{return this.createError(e,t,r,s)}break;case"custom":break;default:console.warn(`Unknown validation rule type: ${s.type}`)}return null}static createError(e,t,r,i){return{fieldId:e,conceptId:t,columnId:r,message:i.message,severity:i.severity||"error",rule:i}}static validateDataType(e,t){if(null==e||""===e)return{valid:!0,convertedValue:e};switch(t){case"number":case"decimal":case"currency":case"percentage":{const t=Number(e);return isNaN(t)?{valid:!1,error:"Invalid number format"}:{valid:!0,convertedValue:t}}case"date":{const t=new Date(e);return isNaN(t.getTime())?{valid:!1,error:"Invalid date format"}:{valid:!0,convertedValue:t.toISOString().split("T")[0]}}case"datetime":{const t=new Date(e);return isNaN(t.getTime())?{valid:!1,error:"Invalid datetime format"}:{valid:!0,convertedValue:t.toISOString()}}case"boolean":if("boolean"==typeof e)return{valid:!0,convertedValue:e};if("string"==typeof e){const t=e.toLowerCase();if("true"===t||"1"===t)return{valid:!0,convertedValue:!0};if("false"===t||"0"===t)return{valid:!0,convertedValue:!1}}return{valid:!1,error:"Invalid boolean format"};case"text":case"textarea":case"email":case"url":case"tel":return{valid:!0,convertedValue:String(e)};default:return{valid:!0,convertedValue:e}}}static formatValue(e,t,r="en-US"){if(null==e)return"";switch(t){case"number":return new Intl.NumberFormat(r).format(Number(e));case"decimal":return new Intl.NumberFormat(r,{minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(e));case"currency":return new Intl.NumberFormat(r,{style:"currency",currency:"USD"}).format(Number(e));case"percentage":return new Intl.NumberFormat(r,{style:"percent",minimumFractionDigits:2}).format(Number(e)/100);case"date":return new Date(e).toLocaleDateString(r);case"datetime":return new Date(e).toLocaleString(r);default:return String(e)}}}class k{static buildFormSchema(e){if(!e.presentation||0===e.presentation.length)throw new Error("XBRL presentation data is required");const t=e.presentation[0],r=[];return t.roles.forEach(e=>{const t=this.buildSectionFromRole(e);r.push(t)}),{formId:`xbrl-form-${Date.now()}`,title:`XBRL Form - ${this.extractEntityName(t.entrypoint)}`,description:"Dynamic form generated from XBRL taxonomy data",version:"1.0.0",sections:r}}static buildSectionFromRole(e){var t;const r=this.extractRoleTitle(e.role),i=[];return(null==(t=e.presentationLinkbase)?void 0:t.concepts)&&e.presentationLinkbase.concepts.forEach(e=>{const t=this.buildConceptTree(e,0);t&&i.push(t)}),{id:e.id,title:r,description:`Section for ${r}`,concepts:i,expanded:!1}}static buildConceptTree(e,t){const r=this.getPreferredLabel(e.labels),i=[];if(!e.elementAbstract){const t=this.createFieldFromConcept(e);t&&i.push(t)}const o=[];return e.children&&e.children.length>0&&e.children.forEach(e=>{const r=this.buildConceptTree(e,t+1);r&&o.push(r)}),{id:e.id,name:e.conceptName,label:r,description:`${e.conceptName} (${e.type})`,level:t,children:o,fields:i,collapsed:t>0}}static createFieldFromConcept(e){const t=this.mapXBRLTypeToFieldType(e.type),r=this.getPreferredLabel(e.labels);return{id:`${e.id}_field`,conceptId:e.id,columnId:"default",type:t,label:r,placeholder:`Enter ${r.toLowerCase()}`,required:!1,disabled:e.elementAbstract,defaultValue:null}}static mapXBRLTypeToFieldType(e){return{"xbrli:stringItemType":"text","xbrli:monetaryItemType":"currency","xbrli:integerItemType":"number","xbrli:decimalItemType":"decimal","xbrli:percentItemType":"percentage","xbrli:dateItemType":"date","xbrli:booleanItemType":"boolean","dtr-types:domainItemType":"select","bw2-titel9:chamberOfCommerceRegistrationNumberItemType":"text"}[e]||"text"}static getPreferredLabel(e){if(!e||0===e.length)return"Unnamed Concept";const t=e.find(e=>e.preferredLabel);if(t)return t.label;const r=e.find(e=>"http://www.xbrl.org/2003/role/label"===e.role);if(r)return r.label;const i=e.find(e=>"http://www.xbrl.org/2003/role/terseLabel"===e.role);return i?i.label:e[0].label}static extractEntityName(e){try{const t=new URL(e).pathname.split("/");return t[t.length-1].replace(".xsd","").replace(/[^a-zA-Z0-9]/g," ").trim()||"Entity"}catch{return"Entity"}}static extractRoleTitle(e){const t=e.match(/^\[[\d]+\]\s*(.+)$/);return t?t[1].trim():e}static extractRoleOrder(e){const t=e.match(/^\[([\d]+)\]/);return t?parseInt(t[1],10):0}static buildColumnsFromHypercubes(){return[{id:"default",label:"Values",type:"data"}]}}var C=Object.defineProperty,D=Object.getOwnPropertyDescriptor,I=(e,t,r,i)=>{for(var o,s=i>1?void 0:i?D(t,r):t,a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i?o(t,r,s):o(s))||s);return i&&s&&C(t,r,s),s};exports.JupiterFormField=class extends e.LitElement{constructor(){super(...arguments),this.value=null,this.disabled=!1,this.locale="en-US",this._errors=[],this._touched=!1}willUpdate(e){(e.has("value")||e.has("field"))&&this._validateField()}_validateField(){var e;(null==(e=this.field)?void 0:e.validation)&&(this._errors=F.validateField(this.field.id,this.conceptId,this.columnId,this.value,this.field.type,this.field.validation))}_handleInput(e){const t=e.target;let r=t.value;"number"===this.field.type||"decimal"===this.field.type?r=""===r?null:Number(r):"boolean"===this.field.type&&(r=t.checked),this.value=r,this._touched=!0,this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,value:r,oldValue:this.value},bubbles:!0}))}_handleFocus(){this.dispatchEvent(new CustomEvent("field-focus",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId},bubbles:!0}))}_handleBlur(){this._touched=!0,this.dispatchEvent(new CustomEvent("field-blur",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId},bubbles:!0}))}_renderInput(){var t;const r=this._errors.some(e=>"error"===e.severity),i=this._errors.some(e=>"warning"===e.severity),o="field-input "+(r?"error":i?"warning":"");switch(this.field.type){case"textarea":return e.html`
|
|
23
|
+
<textarea
|
|
24
|
+
class="${o}"
|
|
25
|
+
.value="${this.value||""}"
|
|
26
|
+
?disabled="${this.disabled||this.field.disabled}"
|
|
27
|
+
placeholder="${this.field.placeholder||""}"
|
|
28
|
+
@input="${this._handleInput}"
|
|
29
|
+
@focus="${this._handleFocus}"
|
|
30
|
+
@blur="${this._handleBlur}"
|
|
31
|
+
></textarea>
|
|
32
|
+
`;case"select":return e.html`
|
|
33
|
+
<select
|
|
34
|
+
class="${o}"
|
|
35
|
+
.value="${this.value||""}"
|
|
36
|
+
?disabled="${this.disabled||this.field.disabled}"
|
|
37
|
+
@change="${this._handleInput}"
|
|
38
|
+
@focus="${this._handleFocus}"
|
|
39
|
+
@blur="${this._handleBlur}"
|
|
40
|
+
>
|
|
41
|
+
<option value="">Select...</option>
|
|
42
|
+
${null==(t=this.field.options)?void 0:t.map(t=>e.html`
|
|
43
|
+
<option
|
|
44
|
+
value="${t.value}"
|
|
45
|
+
?disabled="${t.disabled}"
|
|
46
|
+
?selected="${this.value===t.value}"
|
|
47
|
+
>
|
|
48
|
+
${t.label}
|
|
49
|
+
</option>
|
|
50
|
+
`)}
|
|
51
|
+
</select>
|
|
52
|
+
`;case"boolean":return e.html`
|
|
53
|
+
<div class="checkbox-container">
|
|
54
|
+
<input
|
|
55
|
+
type="checkbox"
|
|
56
|
+
class="field-input"
|
|
57
|
+
.checked="${Boolean(this.value)}"
|
|
58
|
+
?disabled="${this.disabled||this.field.disabled}"
|
|
59
|
+
@change="${this._handleInput}"
|
|
60
|
+
@focus="${this._handleFocus}"
|
|
61
|
+
@blur="${this._handleBlur}"
|
|
62
|
+
/>
|
|
63
|
+
<span>${this.field.label}</span>
|
|
64
|
+
</div>
|
|
65
|
+
`;default:return e.html`
|
|
66
|
+
<input
|
|
67
|
+
type="${this._getInputType()}"
|
|
68
|
+
class="${o}"
|
|
69
|
+
.value="${this.value||""}"
|
|
70
|
+
?disabled="${this.disabled||this.field.disabled}"
|
|
71
|
+
placeholder="${this.field.placeholder||""}"
|
|
72
|
+
@input="${this._handleInput}"
|
|
73
|
+
@focus="${this._handleFocus}"
|
|
74
|
+
@blur="${this._handleBlur}"
|
|
75
|
+
/>
|
|
76
|
+
`}}_getInputType(){switch(this.field.type){case"number":case"decimal":case"currency":case"percentage":return"number";case"date":return"date";case"datetime":return"datetime-local";case"email":return"email";case"url":return"url";case"tel":return"tel";default:return"text"}}render(){const t="boolean"!==this.field.type;return e.html`
|
|
77
|
+
<div class="field-container">
|
|
78
|
+
${t?e.html`
|
|
79
|
+
<label class="field-label ${this.field.required?"required":""}">
|
|
80
|
+
${this.field.label}
|
|
81
|
+
</label>
|
|
82
|
+
`:""}
|
|
83
|
+
|
|
84
|
+
${this._renderInput()}
|
|
85
|
+
|
|
86
|
+
${this._errors.length>0&&this._touched?e.html`
|
|
87
|
+
<div class="field-errors">
|
|
88
|
+
${this._errors.map(t=>e.html`
|
|
89
|
+
<span class="field-error ${t.severity}">
|
|
90
|
+
${t.message}
|
|
91
|
+
</span>
|
|
92
|
+
`)}
|
|
93
|
+
</div>
|
|
94
|
+
`:""}
|
|
95
|
+
</div>
|
|
96
|
+
`}},exports.JupiterFormField.styles=e.css`
|
|
97
|
+
:host {
|
|
98
|
+
display: block;
|
|
99
|
+
margin-bottom: 8px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.field-container {
|
|
103
|
+
position: relative;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.field-label {
|
|
107
|
+
display: block;
|
|
108
|
+
font-weight: 500;
|
|
109
|
+
margin-bottom: 4px;
|
|
110
|
+
color: var(--jupiter-text-primary, #333);
|
|
111
|
+
font-size: 14px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.field-label.required::after {
|
|
115
|
+
content: ' *';
|
|
116
|
+
color: var(--jupiter-error-color, #d32f2f);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.field-input {
|
|
120
|
+
width: 100%;
|
|
121
|
+
padding: 8px 12px;
|
|
122
|
+
border: 1px solid var(--jupiter-border-color, #ddd);
|
|
123
|
+
border-radius: 4px;
|
|
124
|
+
font-size: 14px;
|
|
125
|
+
font-family: inherit;
|
|
126
|
+
background: var(--jupiter-input-background, #fff);
|
|
127
|
+
color: var(--jupiter-text-primary, #333);
|
|
128
|
+
box-sizing: border-box;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.field-input:focus {
|
|
132
|
+
outline: none;
|
|
133
|
+
border-color: var(--jupiter-primary-color, #1976d2);
|
|
134
|
+
box-shadow: 0 0 0 2px var(--jupiter-primary-color-light, rgba(25, 118, 210, 0.2));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.field-input:disabled {
|
|
138
|
+
background: var(--jupiter-disabled-background, #f5f5f5);
|
|
139
|
+
color: var(--jupiter-disabled-text, #999);
|
|
140
|
+
cursor: not-allowed;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.field-input.error {
|
|
144
|
+
border-color: var(--jupiter-error-color, #d32f2f);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.field-input.warning {
|
|
148
|
+
border-color: var(--jupiter-warning-color, #ff9800);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.field-errors {
|
|
152
|
+
margin-top: 4px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.field-error {
|
|
156
|
+
display: block;
|
|
157
|
+
font-size: 12px;
|
|
158
|
+
margin-bottom: 2px;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.field-error.error {
|
|
162
|
+
color: var(--jupiter-error-color, #d32f2f);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.field-error.warning {
|
|
166
|
+
color: var(--jupiter-warning-color, #ff9800);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.field-error.info {
|
|
170
|
+
color: var(--jupiter-info-color, #2196f3);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
select.field-input {
|
|
174
|
+
appearance: none;
|
|
175
|
+
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
|
|
176
|
+
background-position: right 8px center;
|
|
177
|
+
background-repeat: no-repeat;
|
|
178
|
+
background-size: 16px;
|
|
179
|
+
padding-right: 32px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
textarea.field-input {
|
|
183
|
+
resize: vertical;
|
|
184
|
+
min-height: 60px;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.checkbox-container {
|
|
188
|
+
display: flex;
|
|
189
|
+
align-items: center;
|
|
190
|
+
gap: 8px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.checkbox-container input[type="checkbox"] {
|
|
194
|
+
margin: 0;
|
|
195
|
+
width: auto;
|
|
196
|
+
}
|
|
197
|
+
`,I([S({type:Object})],exports.JupiterFormField.prototype,"field",2),I([S({type:String})],exports.JupiterFormField.prototype,"conceptId",2),I([S({type:String})],exports.JupiterFormField.prototype,"columnId",2),I([S()],exports.JupiterFormField.prototype,"value",2),I([S({type:Boolean})],exports.JupiterFormField.prototype,"disabled",2),I([S({type:String})],exports.JupiterFormField.prototype,"locale",2),I([j()],exports.JupiterFormField.prototype,"_errors",2),I([j()],exports.JupiterFormField.prototype,"_touched",2),exports.JupiterFormField=I([t("jupiter-form-field")],exports.JupiterFormField);var P=Object.defineProperty,O=Object.getOwnPropertyDescriptor,J=(e,t,r,i)=>{for(var o,s=i>1?void 0:i?O(t,r):t,a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i?o(t,r,s):o(s))||s);return i&&s&&P(t,r,s),s};exports.JupiterConceptTree=class extends e.LitElement{constructor(){super(...arguments),this.columns=[],this.formData={},this.disabled=!1,this.locale="en-US",this._expanded=!0}connectedCallback(){super.connectedCallback(),this._expanded=!this.concept.collapsed}_toggleExpanded(){this._expanded=!this._expanded,this.dispatchEvent(new CustomEvent("concept-expand",{detail:{conceptId:this.concept.id,expanded:this._expanded},bubbles:!0}))}_getFieldForColumn(e){return this.concept.fields.find(t=>t.columnId===e)}_getFieldValue(e){var t;return null==(t=this.formData[this.concept.id])?void 0:t[e.columnId]}_handleFieldChange(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("field-change",{detail:e.detail,bubbles:!0}))}render(){const t=this.concept.children&&this.concept.children.length>0,r=this.concept.level||0;return e.html`
|
|
198
|
+
<div class="concept-row" style="--level: ${r}">
|
|
199
|
+
<!-- Concept Label Column -->
|
|
200
|
+
<div class="concept-header" @click="${this._toggleExpanded}">
|
|
201
|
+
<div class="concept-indent"></div>
|
|
202
|
+
<div class="concept-toggle ${t?this._expanded?"expanded":"":"no-children"}">
|
|
203
|
+
${t?"▶":""}
|
|
204
|
+
</div>
|
|
205
|
+
<div class="concept-label">
|
|
206
|
+
${this.concept.label}
|
|
207
|
+
${this.concept.description?e.html`
|
|
208
|
+
<span class="concept-description">${this.concept.description}</span>
|
|
209
|
+
`:""}
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<!-- Field Columns -->
|
|
214
|
+
${this.columns.map(t=>{const r=this._getFieldForColumn(t.id);return e.html`
|
|
215
|
+
<div class="field-cell ${r?"":"empty"}">
|
|
216
|
+
${r?e.html`
|
|
217
|
+
<jupiter-form-field
|
|
218
|
+
.field="${r}"
|
|
219
|
+
.conceptId="${this.concept.id}"
|
|
220
|
+
.columnId="${t.id}"
|
|
221
|
+
.value="${this._getFieldValue(r)}"
|
|
222
|
+
.disabled="${this.disabled}"
|
|
223
|
+
.locale="${this.locale}"
|
|
224
|
+
@field-change="${this._handleFieldChange}"
|
|
225
|
+
></jupiter-form-field>
|
|
226
|
+
`:""}
|
|
227
|
+
</div>
|
|
228
|
+
`})}
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
<!-- Children Concepts -->
|
|
232
|
+
${t?e.html`
|
|
233
|
+
<div class="children ${this._expanded?"":"collapsed"}">
|
|
234
|
+
${this.concept.children.map(t=>e.html`
|
|
235
|
+
<jupiter-concept-tree
|
|
236
|
+
.concept="${t}"
|
|
237
|
+
.columns="${this.columns}"
|
|
238
|
+
.formData="${this.formData}"
|
|
239
|
+
.disabled="${this.disabled}"
|
|
240
|
+
.locale="${this.locale}"
|
|
241
|
+
@field-change="${this._handleFieldChange}"
|
|
242
|
+
@concept-expand="${e=>{e.stopPropagation(),this.dispatchEvent(new CustomEvent("concept-expand",{detail:e.detail,bubbles:!0}))}}"
|
|
243
|
+
></jupiter-concept-tree>
|
|
244
|
+
`)}
|
|
245
|
+
</div>
|
|
246
|
+
`:""}
|
|
247
|
+
`}},exports.JupiterConceptTree.styles=e.css`
|
|
248
|
+
:host {
|
|
249
|
+
display: block;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.concept-row {
|
|
253
|
+
display: contents;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.concept-header {
|
|
257
|
+
display: flex;
|
|
258
|
+
align-items: center;
|
|
259
|
+
padding: 8px 12px;
|
|
260
|
+
background: var(--jupiter-concept-background, #f8f9fa);
|
|
261
|
+
border: 1px solid var(--jupiter-border-color, #ddd);
|
|
262
|
+
border-bottom: none;
|
|
263
|
+
font-weight: 500;
|
|
264
|
+
cursor: pointer;
|
|
265
|
+
user-select: none;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.concept-header:hover {
|
|
269
|
+
background: var(--jupiter-concept-hover-background, #e9ecef);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.concept-indent {
|
|
273
|
+
width: calc(var(--level, 0) * 20px);
|
|
274
|
+
flex-shrink: 0;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.concept-toggle {
|
|
278
|
+
width: 16px;
|
|
279
|
+
height: 16px;
|
|
280
|
+
margin-right: 8px;
|
|
281
|
+
display: flex;
|
|
282
|
+
align-items: center;
|
|
283
|
+
justify-content: center;
|
|
284
|
+
font-size: 12px;
|
|
285
|
+
transition: transform 0.2s ease;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.concept-toggle.expanded {
|
|
289
|
+
transform: rotate(90deg);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.concept-toggle.no-children {
|
|
293
|
+
visibility: hidden;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.concept-label {
|
|
297
|
+
flex: 1;
|
|
298
|
+
color: var(--jupiter-text-primary, #333);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.concept-description {
|
|
302
|
+
font-size: 12px;
|
|
303
|
+
color: var(--jupiter-text-secondary, #666);
|
|
304
|
+
font-weight: normal;
|
|
305
|
+
margin-left: 8px;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.concept-fields {
|
|
309
|
+
display: contents;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.field-cell {
|
|
313
|
+
border: 1px solid var(--jupiter-border-color, #ddd);
|
|
314
|
+
border-bottom: none;
|
|
315
|
+
padding: 8px;
|
|
316
|
+
background: var(--jupiter-cell-background, #fff);
|
|
317
|
+
min-height: 40px;
|
|
318
|
+
display: flex;
|
|
319
|
+
align-items: center;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.field-cell:last-child {
|
|
323
|
+
border-right: 1px solid var(--jupiter-border-color, #ddd);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.field-cell.empty {
|
|
327
|
+
background: var(--jupiter-empty-cell-background, #f8f9fa);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.children {
|
|
331
|
+
display: contents;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.children.collapsed {
|
|
335
|
+
display: none;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.concept-row:last-of-type .concept-header,
|
|
339
|
+
.concept-row:last-of-type .field-cell {
|
|
340
|
+
border-bottom: 1px solid var(--jupiter-border-color, #ddd);
|
|
341
|
+
}
|
|
342
|
+
`,J([S({type:Object})],exports.JupiterConceptTree.prototype,"concept",2),J([S({type:Array})],exports.JupiterConceptTree.prototype,"columns",2),J([S({type:Object})],exports.JupiterConceptTree.prototype,"formData",2),J([S({type:Boolean})],exports.JupiterConceptTree.prototype,"disabled",2),J([S({type:String})],exports.JupiterConceptTree.prototype,"locale",2),J([j()],exports.JupiterConceptTree.prototype,"_expanded",2),exports.JupiterConceptTree=J([t("jupiter-concept-tree")],exports.JupiterConceptTree);var U=Object.defineProperty,T=Object.getOwnPropertyDescriptor,R=(e,t,r,i)=>{for(var o,s=i>1?void 0:i?T(t,r):t,a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i?o(t,r,s):o(s))||s);return i&&s&&U(t,r,s),s};exports.JupiterFormSection=class extends e.LitElement{constructor(){super(...arguments),this.columns=[],this.formData={},this.disabled=!1,this.collapsible=!0,this.locale="en-US",this._expanded=!0}connectedCallback(){super.connectedCallback(),this._expanded=!1!==this.section.expanded}_toggleExpanded(){this.collapsible&&(this._expanded=!this._expanded,this.dispatchEvent(new CustomEvent("section-expand",{detail:{sectionId:this.section.id,expanded:this._expanded},bubbles:!0})))}_handleRemoveColumn(e){this.dispatchEvent(new CustomEvent("column-remove",{detail:{columnId:e},bubbles:!0}))}_handleFieldChange(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("field-change",{detail:e.detail,bubbles:!0}))}_handleConceptExpand(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("concept-expand",{detail:e.detail,bubbles:!0}))}render(){return this.section.concepts&&0!==this.section.concepts.length?e.html`
|
|
343
|
+
<div class="section-header ${this.collapsible?"":"not-collapsible"}"
|
|
344
|
+
@click="${this._toggleExpanded}">
|
|
345
|
+
<div>
|
|
346
|
+
<h3 class="section-title">${this.section.title}</h3>
|
|
347
|
+
${this.section.description?e.html`
|
|
348
|
+
<p class="section-description">${this.section.description}</p>
|
|
349
|
+
`:""}
|
|
350
|
+
</div>
|
|
351
|
+
<div class="section-toggle ${this.collapsible?this._expanded?"expanded":"":"hidden"}">
|
|
352
|
+
${this.collapsible?"▶":""}
|
|
353
|
+
</div>
|
|
354
|
+
</div>
|
|
355
|
+
|
|
356
|
+
<div class="section-content ${this._expanded?"":"collapsed"}">
|
|
357
|
+
<div class="table-container">
|
|
358
|
+
<table class="form-table">
|
|
359
|
+
<thead class="table-header">
|
|
360
|
+
<tr>
|
|
361
|
+
<th class="header-cell concept-column">Concept</th>
|
|
362
|
+
${this.columns.map(t=>e.html`
|
|
363
|
+
<th class="header-cell ${t.removable?"removable":""}">
|
|
364
|
+
${t.title}
|
|
365
|
+
${t.description?e.html`<div style="font-weight: normal; font-size: 12px; color: var(--jupiter-text-secondary, #666);">${t.description}</div>`:""}
|
|
366
|
+
${t.removable?e.html`
|
|
367
|
+
<button
|
|
368
|
+
class="remove-column-btn"
|
|
369
|
+
@click="${e=>{e.stopPropagation(),this._handleRemoveColumn(t.id)}}"
|
|
370
|
+
title="Remove column"
|
|
371
|
+
>×</button>
|
|
372
|
+
`:""}
|
|
373
|
+
</th>
|
|
374
|
+
`)}
|
|
375
|
+
</tr>
|
|
376
|
+
</thead>
|
|
377
|
+
<tbody class="table-body">
|
|
378
|
+
${this.section.concepts.map(t=>e.html`
|
|
379
|
+
<jupiter-concept-tree
|
|
380
|
+
.concept="${t}"
|
|
381
|
+
.columns="${this.columns}"
|
|
382
|
+
.formData="${this.formData}"
|
|
383
|
+
.disabled="${this.disabled}"
|
|
384
|
+
.locale="${this.locale}"
|
|
385
|
+
@field-change="${this._handleFieldChange}"
|
|
386
|
+
@concept-expand="${this._handleConceptExpand}"
|
|
387
|
+
></jupiter-concept-tree>
|
|
388
|
+
`)}
|
|
389
|
+
</tbody>
|
|
390
|
+
</table>
|
|
391
|
+
</div>
|
|
392
|
+
</div>
|
|
393
|
+
`:e.html`
|
|
394
|
+
<div class="section-header ${this.collapsible?"":"not-collapsible"}"
|
|
395
|
+
@click="${this._toggleExpanded}">
|
|
396
|
+
<div>
|
|
397
|
+
<h3 class="section-title">${this.section.title}</h3>
|
|
398
|
+
${this.section.description?e.html`
|
|
399
|
+
<p class="section-description">${this.section.description}</p>
|
|
400
|
+
`:""}
|
|
401
|
+
</div>
|
|
402
|
+
<div class="section-toggle ${this.collapsible?this._expanded?"expanded":"":"hidden"}">
|
|
403
|
+
${this.collapsible?"▶":""}
|
|
404
|
+
</div>
|
|
405
|
+
</div>
|
|
406
|
+
|
|
407
|
+
<div class="section-content ${this._expanded?"":"collapsed"}">
|
|
408
|
+
<div class="empty-section">
|
|
409
|
+
No concepts defined for this section.
|
|
410
|
+
</div>
|
|
411
|
+
</div>
|
|
412
|
+
`}},exports.JupiterFormSection.styles=e.css`
|
|
413
|
+
:host {
|
|
414
|
+
display: block;
|
|
415
|
+
margin-bottom: 16px;
|
|
416
|
+
border: 1px solid var(--jupiter-border-color, #ddd);
|
|
417
|
+
border-radius: 6px;
|
|
418
|
+
overflow: hidden;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.section-header {
|
|
422
|
+
background: var(--jupiter-section-header-background, #f0f2f5);
|
|
423
|
+
padding: 16px;
|
|
424
|
+
border-bottom: 1px solid var(--jupiter-border-color, #ddd);
|
|
425
|
+
cursor: pointer;
|
|
426
|
+
user-select: none;
|
|
427
|
+
display: flex;
|
|
428
|
+
align-items: center;
|
|
429
|
+
justify-content: space-between;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.section-header:hover {
|
|
433
|
+
background: var(--jupiter-section-header-hover-background, #e4e7ea);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.section-header.not-collapsible {
|
|
437
|
+
cursor: default;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.section-header.not-collapsible:hover {
|
|
441
|
+
background: var(--jupiter-section-header-background, #f0f2f5);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.section-title {
|
|
445
|
+
font-size: 18px;
|
|
446
|
+
font-weight: 600;
|
|
447
|
+
color: var(--jupiter-text-primary, #333);
|
|
448
|
+
margin: 0;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.section-description {
|
|
452
|
+
font-size: 14px;
|
|
453
|
+
color: var(--jupiter-text-secondary, #666);
|
|
454
|
+
margin: 4px 0 0 0;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.section-toggle {
|
|
458
|
+
width: 24px;
|
|
459
|
+
height: 24px;
|
|
460
|
+
display: flex;
|
|
461
|
+
align-items: center;
|
|
462
|
+
justify-content: center;
|
|
463
|
+
font-size: 16px;
|
|
464
|
+
transition: transform 0.2s ease;
|
|
465
|
+
color: var(--jupiter-text-secondary, #666);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.section-toggle.expanded {
|
|
469
|
+
transform: rotate(90deg);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.section-toggle.hidden {
|
|
473
|
+
visibility: hidden;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.section-content {
|
|
477
|
+
display: block;
|
|
478
|
+
transition: max-height 0.3s ease;
|
|
479
|
+
overflow: hidden;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.section-content.collapsed {
|
|
483
|
+
display: none;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.table-container {
|
|
487
|
+
overflow-x: auto;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
.form-table {
|
|
491
|
+
width: 100%;
|
|
492
|
+
border-collapse: collapse;
|
|
493
|
+
background: var(--jupiter-table-background, #fff);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
.table-header {
|
|
497
|
+
background: var(--jupiter-header-background, #f8f9fa);
|
|
498
|
+
position: sticky;
|
|
499
|
+
top: 0;
|
|
500
|
+
z-index: 1;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.header-cell {
|
|
504
|
+
padding: 12px;
|
|
505
|
+
text-align: left;
|
|
506
|
+
font-weight: 600;
|
|
507
|
+
color: var(--jupiter-text-primary, #333);
|
|
508
|
+
border: 1px solid var(--jupiter-border-color, #ddd);
|
|
509
|
+
background: var(--jupiter-header-background, #f8f9fa);
|
|
510
|
+
min-width: 150px;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
.header-cell.concept-column {
|
|
514
|
+
min-width: 300px;
|
|
515
|
+
position: sticky;
|
|
516
|
+
left: 0;
|
|
517
|
+
z-index: 2;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.header-cell.removable {
|
|
521
|
+
position: relative;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.remove-column-btn {
|
|
525
|
+
position: absolute;
|
|
526
|
+
top: 4px;
|
|
527
|
+
right: 4px;
|
|
528
|
+
width: 20px;
|
|
529
|
+
height: 20px;
|
|
530
|
+
border: none;
|
|
531
|
+
background: var(--jupiter-error-color, #d32f2f);
|
|
532
|
+
color: white;
|
|
533
|
+
border-radius: 50%;
|
|
534
|
+
font-size: 12px;
|
|
535
|
+
cursor: pointer;
|
|
536
|
+
display: flex;
|
|
537
|
+
align-items: center;
|
|
538
|
+
justify-content: center;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.remove-column-btn:hover {
|
|
542
|
+
background: var(--jupiter-error-color-dark, #b71c1c);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
.table-body {
|
|
546
|
+
display: table-row-group;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
.empty-section {
|
|
550
|
+
padding: 24px;
|
|
551
|
+
text-align: center;
|
|
552
|
+
color: var(--jupiter-text-secondary, #666);
|
|
553
|
+
font-style: italic;
|
|
554
|
+
}
|
|
555
|
+
`,R([S({type:Object})],exports.JupiterFormSection.prototype,"section",2),R([S({type:Array})],exports.JupiterFormSection.prototype,"columns",2),R([S({type:Object})],exports.JupiterFormSection.prototype,"formData",2),R([S({type:Boolean})],exports.JupiterFormSection.prototype,"disabled",2),R([S({type:Boolean})],exports.JupiterFormSection.prototype,"collapsible",2),R([S({type:String})],exports.JupiterFormSection.prototype,"locale",2),R([j()],exports.JupiterFormSection.prototype,"_expanded",2),exports.JupiterFormSection=R([t("jupiter-form-section")],exports.JupiterFormSection);var L=Object.defineProperty,z=Object.getOwnPropertyDescriptor,A=(e,t,r,i)=>{for(var o,s=i>1?void 0:i?z(t,r):t,a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i?o(t,r,s):o(s))||s);return i&&s&&L(t,r,s),s};exports.JupiterDynamicForm=class extends e.LitElement{constructor(){super(...arguments),this.config={},this.initialData={},this.disabled=!1,this.readonly=!1,this._formData={},this._columns=[],this._errors=[],this._touched=new Set,this._dirty=!1,this._valid=!0,this._submitted=!1}connectedCallback(){super.connectedCallback(),this._initializeForm()}updated(e){(e.has("xbrlInput")||e.has("schema"))&&this._initializeForm()}_initializeForm(){var e;if(this.xbrlInput)try{console.log("🔄 Initializing form from XBRL input:",this.xbrlInput),this._currentSchema=k.buildFormSchema(this.xbrlInput),console.log("✅ Generated schema with sections:",this._currentSchema.sections.length),this._columns=[{id:"base",title:"Value",description:"Base values for concepts",type:"base",order:0,removable:!1}]}catch(t){console.error("❌ Error building form from XBRL input:",t),this._currentSchema=this._getDefaultSchema(),this._columns=this._getDefaultColumns()}else this.schema?(this._currentSchema=this.schema,this._columns=this._getDefaultColumns()):(this._currentSchema=this._getDefaultSchema(),this._columns=this._getDefaultColumns());this._formData={...this.initialData},(null==(e=this.xbrlInput)?void 0:e.initialData)&&(this._formData={...this._formData,...this.xbrlInput.initialData}),this._validateForm()}_getDefaultSchema(){return{version:"1.0",formId:"default-form",title:"Dynamic Form",description:"Please provide form schema or XBRL input data",sections:[]}}_getDefaultColumns(){return[{id:"base",title:"Value",description:"Base values for concepts",type:"base",order:0,removable:!1}]}_validateForm(){var e;const t=[],r=this._currentSchema;if(r){for(const i of r.sections)for(const r of i.concepts)for(const i of r.fields){const o=null==(e=this._formData[r.id])?void 0:e[i.columnId],s=F.validateField(i.id,r.id,i.columnId,o,i.type,i.validation||[]);t.push(...s)}this._errors=t,this._valid=0===t.filter(e=>"error"===e.severity).length}}_handleFieldChange(e){const{fieldId:t,conceptId:r,columnId:i,value:o}=e.detail;this._formData[r]||(this._formData[r]={});const s=this._formData[r][i];this._formData[r][i]=o,this._touched.add(`${r}-${i}`),this._dirty=!0,this._validateForm(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:t,conceptId:r,columnId:i,value:o,oldValue:s},bubbles:!0}))}_handleSectionExpand(e){this.dispatchEvent(new CustomEvent("section-expand",{detail:e.detail,bubbles:!0}))}_handleConceptExpand(e){this.dispatchEvent(new CustomEvent("concept-expand",{detail:e.detail,bubbles:!0}))}_handleColumnRemove(e){const{columnId:t}=e.detail;this._columns=this._columns.filter(e=>e.id!==t);for(const r in this._formData)void 0!==this._formData[r][t]&&delete this._formData[r][t];this._dirty=!0,this._validateForm(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-remove",{detail:{columnId:t},bubbles:!0}))}_addColumn(){const e={id:`dim-${Date.now()}`,title:`Dimension ${this._columns.length}`,description:"Additional dimension column",type:"dimension",order:this._columns.length,removable:!0,dimensionData:{dimensionId:"custom",memberValue:"default",memberLabel:"Default Member"}};this._columns=[...this._columns,e],this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-add",{detail:{column:e},bubbles:!0}))}_handleSubmit(){this._submitted=!0,this._validateForm(),this.dispatchEvent(new CustomEvent("form-submit",{detail:{data:this._formData,valid:this._valid,errors:this._errors},bubbles:!0}))}_handleReset(){this._formData={...this.initialData},this._touched.clear(),this._dirty=!1,this._submitted=!1,this._validateForm(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("form-reset",{detail:{},bubbles:!0}))}_getFormState(){return{data:this._formData,errors:this._errors,touched:this._touched,dirty:this._dirty,valid:this._valid,submitted:this._submitted}}getData(){return{...this._formData}}setData(e){this._formData={...e},this._dirty=!0,this._validateForm(),this.requestUpdate()}validate(){return this._validateForm(),this._valid}reset(){this._handleReset()}getState(){return this._getFormState()}render(){const t=this._errors.filter(e=>"error"===e.severity).length,r=!1!==this.config.showValidationSummary&&t>0&&this._submitted,i=this._currentSchema;return i?e.html`
|
|
556
|
+
<div class="form-container">
|
|
557
|
+
<!-- Form Header -->
|
|
558
|
+
<div class="form-header">
|
|
559
|
+
<h1 class="form-title">${i.title}</h1>
|
|
560
|
+
${i.description?e.html`
|
|
561
|
+
<p class="form-description">${i.description}</p>
|
|
562
|
+
`:""}
|
|
563
|
+
</div>
|
|
564
|
+
|
|
565
|
+
<!-- Add Column Section -->
|
|
566
|
+
${!1!==this.config.enableColumnManagement?e.html`
|
|
567
|
+
<div class="add-column-container">
|
|
568
|
+
<button
|
|
569
|
+
class="add-column-btn"
|
|
570
|
+
@click="${this._addColumn}"
|
|
571
|
+
?disabled="${this.disabled||this.readonly||this.config.maxColumns&&this._columns.length>=this.config.maxColumns}"
|
|
572
|
+
>
|
|
573
|
+
Add Dimension Column
|
|
574
|
+
</button>
|
|
575
|
+
</div>
|
|
576
|
+
`:""}
|
|
577
|
+
|
|
578
|
+
<!-- Form Content -->
|
|
579
|
+
<div class="form-sections">
|
|
580
|
+
<!-- Validation Summary -->
|
|
581
|
+
${r?e.html`
|
|
582
|
+
<div class="validation-summary">
|
|
583
|
+
<h4 class="validation-summary-title">Please fix the following errors:</h4>
|
|
584
|
+
<ul class="validation-summary-list">
|
|
585
|
+
${this._errors.filter(e=>"error"===e.severity).map(t=>e.html`
|
|
586
|
+
<li class="validation-summary-item">${t.message}</li>
|
|
587
|
+
`)}
|
|
588
|
+
</ul>
|
|
589
|
+
</div>
|
|
590
|
+
`:""}
|
|
591
|
+
|
|
592
|
+
<!-- Form Sections -->
|
|
593
|
+
${i.sections.map(t=>e.html`
|
|
594
|
+
<jupiter-form-section
|
|
595
|
+
.section="${t}"
|
|
596
|
+
.columns="${this._columns}"
|
|
597
|
+
.formData="${this._formData}"
|
|
598
|
+
.disabled="${this.disabled||this.readonly}"
|
|
599
|
+
.collapsible="${!1!==this.config.collapsibleSections}"
|
|
600
|
+
.locale="${this.config.locale||"en-US"}"
|
|
601
|
+
@field-change="${this._handleFieldChange}"
|
|
602
|
+
@section-expand="${this._handleSectionExpand}"
|
|
603
|
+
@concept-expand="${this._handleConceptExpand}"
|
|
604
|
+
@column-remove="${this._handleColumnRemove}"
|
|
605
|
+
></jupiter-form-section>
|
|
606
|
+
`)}
|
|
607
|
+
</div>
|
|
608
|
+
|
|
609
|
+
<!-- Form Actions -->
|
|
610
|
+
<div class="form-actions">
|
|
611
|
+
<button
|
|
612
|
+
class="btn-primary"
|
|
613
|
+
@click="${this._handleSubmit}"
|
|
614
|
+
?disabled="${this.disabled||this.readonly}"
|
|
615
|
+
>
|
|
616
|
+
Submit
|
|
617
|
+
</button>
|
|
618
|
+
|
|
619
|
+
<button
|
|
620
|
+
class="btn-outline"
|
|
621
|
+
@click="${this._handleReset}"
|
|
622
|
+
?disabled="${this.disabled||!this._dirty}"
|
|
623
|
+
>
|
|
624
|
+
Reset
|
|
625
|
+
</button>
|
|
626
|
+
|
|
627
|
+
<div class="form-meta">
|
|
628
|
+
<span>Errors: ${t}</span>
|
|
629
|
+
<span>Modified: ${this._dirty?"Yes":"No"}</span>
|
|
630
|
+
<span>Valid: ${this._valid?"Yes":"No"}</span>
|
|
631
|
+
</div>
|
|
632
|
+
</div>
|
|
633
|
+
</div>
|
|
634
|
+
`:e.html`<div>Loading form...</div>`}},exports.JupiterDynamicForm.styles=e.css`
|
|
635
|
+
:host {
|
|
636
|
+
display: block;
|
|
637
|
+
font-family: var(--jupiter-font-family, system-ui, -apple-system, sans-serif);
|
|
638
|
+
color: var(--jupiter-text-primary, #333);
|
|
639
|
+
background: var(--jupiter-background, #fff);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.form-container {
|
|
643
|
+
width: 100%;
|
|
644
|
+
max-width: var(--jupiter-max-width, none);
|
|
645
|
+
margin: 0 auto;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
.form-header {
|
|
649
|
+
padding: 24px;
|
|
650
|
+
border-bottom: 1px solid var(--jupiter-border-color, #ddd);
|
|
651
|
+
background: var(--jupiter-form-header-background, #fff);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
.form-title {
|
|
655
|
+
font-size: 24px;
|
|
656
|
+
font-weight: 600;
|
|
657
|
+
margin: 0 0 8px 0;
|
|
658
|
+
color: var(--jupiter-text-primary, #333);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.form-description {
|
|
662
|
+
font-size: 16px;
|
|
663
|
+
color: var(--jupiter-text-secondary, #666);
|
|
664
|
+
margin: 0;
|
|
665
|
+
line-height: 1.5;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
.form-actions {
|
|
669
|
+
padding: 16px 24px;
|
|
670
|
+
border-top: 1px solid var(--jupiter-border-color, #ddd);
|
|
671
|
+
background: var(--jupiter-form-actions-background, #f8f9fa);
|
|
672
|
+
display: flex;
|
|
673
|
+
gap: 12px;
|
|
674
|
+
align-items: center;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
.add-column-container {
|
|
678
|
+
padding: 16px 24px;
|
|
679
|
+
border-bottom: 1px solid var(--jupiter-border-color, #ddd);
|
|
680
|
+
background: var(--jupiter-form-actions-background, #f8f9fa);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
.add-column-btn {
|
|
684
|
+
padding: 8px 16px;
|
|
685
|
+
background: var(--jupiter-primary-color, #1976d2);
|
|
686
|
+
color: white;
|
|
687
|
+
border: none;
|
|
688
|
+
border-radius: 4px;
|
|
689
|
+
cursor: pointer;
|
|
690
|
+
font-size: 14px;
|
|
691
|
+
font-weight: 500;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.add-column-btn:hover {
|
|
695
|
+
background: var(--jupiter-primary-color-dark, #1565c0);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
.add-column-btn:disabled {
|
|
699
|
+
background: var(--jupiter-disabled-background, #ccc);
|
|
700
|
+
cursor: not-allowed;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
.form-sections {
|
|
704
|
+
padding: 24px;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
.validation-summary {
|
|
708
|
+
margin-bottom: 16px;
|
|
709
|
+
padding: 16px;
|
|
710
|
+
border-radius: 4px;
|
|
711
|
+
background: var(--jupiter-error-background, #ffebee);
|
|
712
|
+
border: 1px solid var(--jupiter-error-color, #d32f2f);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.validation-summary-title {
|
|
716
|
+
font-weight: 600;
|
|
717
|
+
color: var(--jupiter-error-color, #d32f2f);
|
|
718
|
+
margin: 0 0 8px 0;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
.validation-summary-list {
|
|
722
|
+
margin: 0;
|
|
723
|
+
padding-left: 20px;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.validation-summary-item {
|
|
727
|
+
color: var(--jupiter-error-color, #d32f2f);
|
|
728
|
+
margin-bottom: 4px;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
.form-actions button {
|
|
732
|
+
padding: 10px 20px;
|
|
733
|
+
border: none;
|
|
734
|
+
border-radius: 4px;
|
|
735
|
+
font-size: 14px;
|
|
736
|
+
font-weight: 500;
|
|
737
|
+
cursor: pointer;
|
|
738
|
+
transition: background-color 0.2s ease;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
.btn-primary {
|
|
742
|
+
background: var(--jupiter-primary-color, #1976d2);
|
|
743
|
+
color: white;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
.btn-primary:hover:not(:disabled) {
|
|
747
|
+
background: var(--jupiter-primary-color-dark, #1565c0);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
.btn-secondary {
|
|
751
|
+
background: var(--jupiter-secondary-color, #757575);
|
|
752
|
+
color: white;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.btn-secondary:hover:not(:disabled) {
|
|
756
|
+
background: var(--jupiter-secondary-color-dark, #616161);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
.btn-outline {
|
|
760
|
+
background: transparent;
|
|
761
|
+
color: var(--jupiter-primary-color, #1976d2);
|
|
762
|
+
border: 1px solid var(--jupiter-primary-color, #1976d2);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
.btn-outline:hover:not(:disabled) {
|
|
766
|
+
background: var(--jupiter-primary-color, #1976d2);
|
|
767
|
+
color: white;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
button:disabled {
|
|
771
|
+
opacity: 0.6;
|
|
772
|
+
cursor: not-allowed;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
.form-meta {
|
|
776
|
+
display: flex;
|
|
777
|
+
gap: 16px;
|
|
778
|
+
align-items: center;
|
|
779
|
+
font-size: 12px;
|
|
780
|
+
color: var(--jupiter-text-secondary, #666);
|
|
781
|
+
margin-left: auto;
|
|
782
|
+
}
|
|
783
|
+
`,A([S({type:Object})],exports.JupiterDynamicForm.prototype,"schema",2),A([S({type:Object})],exports.JupiterDynamicForm.prototype,"xbrlInput",2),A([S({type:Object})],exports.JupiterDynamicForm.prototype,"config",2),A([S({type:Object})],exports.JupiterDynamicForm.prototype,"initialData",2),A([S({type:Boolean})],exports.JupiterDynamicForm.prototype,"disabled",2),A([S({type:Boolean})],exports.JupiterDynamicForm.prototype,"readonly",2),A([j()],exports.JupiterDynamicForm.prototype,"_formData",2),A([j()],exports.JupiterDynamicForm.prototype,"_columns",2),A([j()],exports.JupiterDynamicForm.prototype,"_errors",2),A([j()],exports.JupiterDynamicForm.prototype,"_touched",2),A([j()],exports.JupiterDynamicForm.prototype,"_dirty",2),A([j()],exports.JupiterDynamicForm.prototype,"_valid",2),A([j()],exports.JupiterDynamicForm.prototype,"_submitted",2),A([j()],exports.JupiterDynamicForm.prototype,"_currentSchema",2),exports.JupiterDynamicForm=A([t("jupiter-dynamic-form")],exports.JupiterDynamicForm);exports.FormValidator=F,exports.version="1.0.0";
|
|
784
|
+
//# sourceMappingURL=index.js.map
|