@foxy.io/elements 1.16.0-beta.10 → 1.16.0-beta.11
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/dist/cdn/foxy-access-recovery-form.js +1 -1
- package/dist/cdn/foxy-address-card.js +1 -1
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-api-browser.js +1 -1
- package/dist/cdn/foxy-applied-tax-card.js +1 -1
- package/dist/cdn/foxy-attribute-card.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-collection-page.js +1 -1
- package/dist/cdn/foxy-collection-pages.js +1 -1
- package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
- package/dist/cdn/foxy-coupon-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-coupon-codes-form.js +1 -1
- package/dist/cdn/foxy-coupon-detail-card.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-custom-field-card.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-api.js +1 -1
- package/dist/cdn/foxy-customer-card.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-builder.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-discount-detail-card.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.js +1 -1
- package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-item-card.js +1 -1
- package/dist/cdn/foxy-item-form.js +1 -1
- package/dist/cdn/foxy-item-option-card.js +1 -1
- package/dist/cdn/foxy-item-option-form.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-pagination.js +1 -1
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-report-form.js +6 -6
- package/dist/cdn/foxy-reports-table.js +1 -1
- package/dist/cdn/foxy-shipment-card.js +2 -2
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +4 -4
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-tax-card.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transaction.js +2 -2
- package/dist/cdn/foxy-transactions-table.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/foxy-webhook-form.js +1 -1
- package/dist/cdn/{shared-a0617ac7.js → shared-31f90f98.js} +1 -1
- package/dist/cdn/shared-41df4012.js +1 -0
- package/dist/cdn/{shared-6f03b699.js → shared-5323ef71.js} +1 -1
- package/dist/cdn/{shared-42883176.js → shared-79bfb59a.js} +1 -1
- package/dist/cdn/{shared-e7634824.js → shared-7e960a32.js} +1 -1
- package/dist/cdn/{shared-a916ce20.js → shared-7facf7ba.js} +1 -1
- package/dist/cdn/shared-90553b38.js +1 -0
- package/dist/cdn/shared-98497473.js +1 -0
- package/dist/cdn/{shared-d8ceb77e.js → shared-b9607e68.js} +1 -1
- package/dist/cdn/{shared-7312e29c.js → shared-be26193a.js} +1 -1
- package/dist/cdn/{shared-df43b0ca.js → shared-cfb3d161.js} +1 -1
- package/dist/cdn/{shared-15b109e0.js → shared-e9a4a204.js} +1 -1
- package/dist/cdn/{shared-8ada26b5.js → shared-f0a57ef6.js} +1 -1
- package/dist/cdn/{shared-fa7e21e7.js → shared-f5419ce4.js} +1 -1
- package/dist/elements/internal/InternalControl/InternalControl.d.ts +22 -2
- package/dist/elements/internal/InternalControl/InternalControl.js +29 -8
- package/dist/elements/internal/InternalControl/InternalControl.js.map +1 -1
- package/dist/elements/internal/InternalControl/index.d.ts +2 -0
- package/dist/elements/internal/InternalControl/index.js +2 -0
- package/dist/elements/internal/InternalControl/index.js.map +1 -1
- package/dist/elements/internal/InternalEditableControl/InternalEditableControl.d.ts +52 -0
- package/dist/elements/internal/InternalEditableControl/InternalEditableControl.js +82 -7
- package/dist/elements/internal/InternalEditableControl/InternalEditableControl.js.map +1 -1
- package/dist/elements/internal/InternalForm/InternalForm.d.ts +16 -0
- package/dist/elements/internal/InternalForm/InternalForm.js +17 -0
- package/dist/elements/internal/InternalForm/InternalForm.js.map +1 -1
- package/dist/elements/internal/InternalForm/index.d.ts +2 -2
- package/dist/elements/internal/InternalForm/index.js +2 -2
- package/dist/elements/internal/InternalForm/index.js.map +1 -1
- package/dist/elements/internal/InternalTimestampsControl/InternalTimestampsControl.d.ts +14 -0
- package/dist/elements/internal/{InternalForm/internal/InternalTimestampsControl → InternalTimestampsControl}/InternalTimestampsControl.js +12 -11
- package/dist/elements/internal/InternalTimestampsControl/InternalTimestampsControl.js.map +1 -0
- package/dist/elements/internal/{InternalForm/internal/InternalTimestampsControl → InternalTimestampsControl}/index.d.ts +2 -0
- package/dist/elements/internal/{InternalForm/internal/InternalTimestampsControl → InternalTimestampsControl}/index.js +2 -0
- package/dist/elements/internal/InternalTimestampsControl/index.js.map +1 -0
- package/dist/mixins/configurable.js +1 -0
- package/dist/mixins/configurable.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-448cf4fc.js +0 -1
- package/dist/cdn/shared-94ec874e.js +0 -1
- package/dist/cdn/shared-997e1923.js +0 -1
- package/dist/elements/internal/InternalForm/internal/InternalTimestampsControl/InternalTimestampsControl.d.ts +0 -8
- package/dist/elements/internal/InternalForm/internal/InternalTimestampsControl/InternalTimestampsControl.js.map +0 -1
- package/dist/elements/internal/InternalForm/internal/InternalTimestampsControl/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,g as t,I as r,_ as n}from"./shared-fadcb2e1.js";import{L as s,h as o}from"./shared-dc73b9a5.js";import{A as i}from"./shared-26ce8d23.js";import"./shared-1bbd9b73.js";import{C as a}from"./shared-
|
|
1
|
+
import{c as e,g as t,I as r,_ as n}from"./shared-fadcb2e1.js";import{L as s,h as o}from"./shared-dc73b9a5.js";import{A as i}from"./shared-26ce8d23.js";import"./shared-1bbd9b73.js";import{C as a}from"./shared-98497473.js";import{F as u}from"./shared-92327224.js";var c=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatCookie=void 0;var r=function(e){var t=e.path,r=e.domain,n=e.expires,s=e.secure,o=function(e){var t=e.sameSite;return void 0===t?null:["none","lax","strict"].indexOf(t.toLowerCase())>=0?t:null}(e);return[null==t?"":";path="+t,null==r?"":";domain="+r,null==n?"":";expires="+n.toUTCString(),void 0===s||!1===s?"":";secure",null===o?"":";SameSite="+o].join("")};t.formatCookie=function(e,t,n){return[encodeURIComponent(e),"=",encodeURIComponent(t),r(n)].join("")}})),l=e((function(e,t){function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,s=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){s=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(s)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}Object.defineProperty(t,"__esModule",{value:!0}),t.parseCookies=void 0;t.parseCookies=function(e){if(0===e.length)return{};var t={},n=new RegExp("\\s*;\\s*");return e.split(n).forEach((function(e){var n=r(e.split("="),2),s=n[0],o=n[1],i=decodeURIComponent(s),a=decodeURIComponent(o);t[i]=a})),t}})),p=e((function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.CookieStorage=void 0;var n=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._defaultOptions=Object.assign({domain:null,expires:null,path:null,secure:!1},t),"undefined"!=typeof Proxy)return new Proxy(this,s)}var t,n,o;return t=e,(n=[{key:"clear",value:function(){var e=this,t=l.parseCookies(this._getCookie());Object.keys(t).forEach((function(t){return e.removeItem(t)}))}},{key:"getItem",value:function(e){var t=l.parseCookies(this._getCookie());return Object.prototype.hasOwnProperty.call(t,e)?t[e]:null}},{key:"key",value:function(e){var t=l.parseCookies(this._getCookie()),r=Object.keys(t).sort();return e<r.length?r[e]:null}},{key:"removeItem",value:function(e,t){var r=Object.assign(Object.assign(Object.assign({},this._defaultOptions),t),{expires:new Date(0)}),n=c.formatCookie(e,"",r);this._setCookie(n)}},{key:"setItem",value:function(e,t,r){var n=Object.assign(Object.assign({},this._defaultOptions),r),s=c.formatCookie(e,t,n);this._setCookie(s)}},{key:"_getCookie",value:function(){return"undefined"==typeof document||void 0===document.cookie?"":document.cookie}},{key:"_setCookie",value:function(e){document.cookie=e}},{key:"length",get:function(){var e=l.parseCookies(this._getCookie());return Object.keys(e).length}}])&&r(t.prototype,n),o&&r(t,o),e}();t.CookieStorage=n;var s={defineProperty:function(e,t,r){return e.setItem(t.toString(),String(r.value)),!0},deleteProperty:function(e,t){return e.removeItem(t.toString()),!0},get:function(e,t,r){if("string"==typeof t&&t in e)return e[t];var n=e.getItem(t.toString());return null!==n?n:void 0},getOwnPropertyDescriptor:function(e,t){if(!(t in e))return{configurable:!0,enumerable:!0,value:e.getItem(t.toString()),writable:!0}},has:function(e,t){return"string"==typeof t&&t in e||null!==e.getItem(t.toString())},ownKeys:function(e){for(var t=[],r=0;r<e.length;r++){var n=e.key(r);null!==n&&t.push(n)}return t},preventExtensions:function(e){throw new TypeError("can't prevent extensions on this proxy object")},set:function(e,t,r,n){return e.setItem(t.toString(),String(r)),!0}}})),f=t(e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"CookieStorage",{enumerable:!0,get:function(){return p.CookieStorage}}),Object.defineProperty(t,"formatCookie",{enumerable:!0,get:function(){return c.formatCookie}}),Object.defineProperty(t,"parseCookies",{enumerable:!0,get:function(){return l.parseCookies}})})));class h extends f.CookieStorage{constructor(){super({sameSite:"Strict",expires:new Date,secure:!0,domain:location.hostname,path:"/"})}getItem(e){if(e===i.SESSION){const e=super.getItem("fx.customer"),t=super.getItem("fx.customer.duration"),r=super.getItem("fx.customer.start"),n=super.getItem("fx.customer.jwt");if(null===e||null===t||null===r||null===n)return null;const s={session_token:e,date_created:r,expires_in:parseInt(t),jwt:n},o=super.getItem("fx.customer.sso");return null!==o&&(s.sso=o),JSON.stringify(s)}return super.getItem(e)}setItem(e,t,r){if(e!==i.SESSION)return super.setItem(e,t,r);{const e=JSON.parse(t),r=1e3*e.expires_in,n=new Date(new Date(e.date_created).getTime()+r);super.setItem("fx.customer",e.session_token,{expires:n}),super.setItem("fx.customer.jwt",e.jwt,{expires:n}),super.setItem("fx.customer.start",e.date_created,{expires:n}),super.setItem("fx.customer.duration",String(e.expires_in),{expires:n}),e.sso&&super.setItem("fx.customer.sso",e.sso,{expires:n})}}clear(){for(let e=0;e<this.length;){const t=super.key(e);t.startsWith("fx.customer")?super.removeItem(t):e++}}}const d=new h;let m,g=e=>e;class _ extends(a(r(s))){constructor(){var e;super(...arguments),e=this,this.__storage="local",this.__level=0,this.__base=location.origin,this.__api=this.__createAPIInstance(),this.__handleFetch=async function(t){if(!(t instanceof u))return;if(t.defaultPrevented)return;if(t.composedPath()[0]===e)return;t.preventDefault();const r=new u("fetch",{cancelable:!0,composed:!0,request:t.request,bubbles:!0,reject:e=>t.respondWith(Promise.reject(e)),resolve:n=>{"foxy://customer-api/session"===r.request.url&&e.requestUpdate(),401===n.status&&e.requestUpdate(),t.respondWith(Promise.resolve(n))}});e.dispatchEvent(r)&&r.respondWith(e.__handleRequest(r.request))}}static get properties(){return n(n({},super.properties),{},{storage:{type:String,noAccessor:!0},level:{type:Number,noAccessor:!0},base:{type:String,noAccessor:!0}})}get isLoggedIn(){return!!this.api.storage.getItem(i.SESSION)}get api(){return this.__api}get base(){return this.__base}set base(e){this.__base=e,this.__api=this.__createAPIInstance()}get level(){return this.__level}set level(e){this.__level=e,this.__api=this.__createAPIInstance()}get storage(){return this.__storage}set storage(e){this.__storage=e,this.__api=this.__createAPIInstance()}connectedCallback(){super.connectedCallback(),this.addEventListener("fetch",this.__handleFetch)}render(){return o(m||(m=g` ${0} <slot></slot> `),this.renderTemplateOrSlot(this.isLoggedIn?"logged-in":"logged-out"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("fetch",this.__handleFetch)}__createAPIInstance(){const e={session:sessionStorage,cookie:d,local:localStorage};return new i({storage:e[this.storage],level:this.level,base:new URL(this.base)})}async __handleVirtualAuthSessionDelete(){return await this.api.signOut(),this.dispatchEvent(new _.SignOutEvent("signout")),this.requestUpdate(),new Response}async __handleVirtualAuthSessionPost(e){const t=await e.clone().json();if("password"!==t.type)throw new Error(`Unknown payload type ${t.type}`);let r,s;try{await this.api.signIn(t.credential),this.dispatchEvent(new _.SignInEvent("signin")),this.requestUpdate(),r=200,s=n({_links:{self:{href:e.url}}},t)}catch(e){if(!(e instanceof i.AuthError))throw e;if("UNAUTHORIZED"!==e.code)throw e;r=401,s={total:1,_embedded:{"fx:errors":[{message:e.message,logref:"unavailable",code:"invalid_credential_error"}]}}}return new Response(JSON.stringify(s),{status:r})}async __handleVirtualAuthRecoverPost(e){const t=await e.clone().json();if("email"===t.type)return await this.api.sendPasswordResetEmail(t.detail),new Response(JSON.stringify({_links:{self:{href:e.url}},email:t.email}));throw new Error(`Unknown payload type ${t.type}`)}async __handleRequest(e){const t=e.url,r=e.method;try{if("foxy://customer-api/session"===t){if("DELETE"===r)return this.__handleVirtualAuthSessionDelete();if("POST"===r)return this.__handleVirtualAuthSessionPost(e)}if("foxy://customer-api/recover"===t&&"POST"===r)return this.__handleVirtualAuthRecoverPost(e);const n=await this.api.fetch(e);return 401===n.status&&(this.api.storage.clear(),this.dispatchEvent(new _.SignOutEvent("signout")),this.requestUpdate()),n}catch(e){return new Response(null,{status:500})}}}_.SignOutEvent=class extends CustomEvent{},_.SignInEvent=class extends CustomEvent{};export{_ as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as t,I as e}from"./shared-fadcb2e1.js";import{h as s,L as i}from"./shared-dc73b9a5.js";import{C as r}from"./shared-
|
|
1
|
+
import{_ as t,I as e}from"./shared-fadcb2e1.js";import{h as s,L as i}from"./shared-dc73b9a5.js";import{C as r}from"./shared-98497473.js";import{a as n,T as o}from"./shared-e82cc599.js";import{c as a}from"./shared-4e709717.js";import{l}from"./shared-22ba9566.js";import{r as c}from"./shared-a0c6a159.js";let d,h,u,m=t=>t;const p=n(r(o(e(i))));class b extends p{constructor(){super(...arguments),this.options=[],this.items=[],this.__newItem=""}static get properties(){return t(t({},super.properties),{},{options:{type:Array},items:{type:Array},__newItem:{attribute:!1}})}render(){const t=a({"w-xs h-xs mr-xs rounded-full transition-colors flex-shrink-0":!0,"focus-outline-none focus-ring-2 ring-inset ring-error-50":!0,"text-tertiary hover-bg-error-10 hover-text-error":!this.disabled,"cursor-default text-disabled":this.disabled,"flex items-center justify-center":!this.readonly,hidden:this.readonly}),e=a({"transition-colors h-l ml-m flex items-center":!0,"text-secondary":this.readonly,"text-disabled":this.disabled}),i=this.disabled||!this.__newItem,r=()=>{this.__newItem&&(this.items.push({value:this.__newItem}),this.requestUpdate("items"),this.dispatchEvent(new CustomEvent("change")),this.__newItem="")};return s(d||(d=m` <slot></slot> <ol class="divide-y divide-contrast-10"> ${0} </ol> <div class="${0}"> <input placeholder="${0}" class="w-full bg-transparent appearance-none h-m focus-outline-none" list="list" .value="${0}" ?disabled="${0}" ?readonly="${0}" @keydown="${0}" @change="${0}" @input="${0}"> <datalist id="list"> ${0} </datalist> <div class="transition-opacity ${0}"> <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon icon="lumo:plus" class="icon-inline text-l"></iron-icon> </button> </div> </div> `),c(this.items,(t=>t.value),((i,r)=>{var n;return s(h||(h=m` <li class="${0}"> <div class="flex-1 mr-s">${0}</div> <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon icon="lumo:cross" class="icon-inline text-xl"></iron-icon> </button> </li> `),e,null!==(n=i.label)&&void 0!==n?n:i.value,this.t("delete"),t,this.disabled,(()=>{this.items.splice(r,1),this.requestUpdate("items"),this.dispatchEvent(new CustomEvent("change"))}))})),a({"ml-m h-l flex items-center":!0,"border-t border-contrast-10":this.items.length>0,flex:!this.readonly,hidden:this.readonly}),this.t("type_here"),l(this.__newItem),this.disabled,this.readonly,(t=>"Enter"===t.key&&r()),(t=>t.stopPropagation()),(t=>{this.__newItem=t.currentTarget.value.trim()}),this.options.map((({label:t,value:e})=>{if(!this.items.some((t=>t.value===e)))return s(u||(u=m`<option value="${0}">${0}</option>`),e,null!=t?t:e)})),this.__newItem?"opacity-100":"opacity-0",this.t("submit"),a({"w-xs h-xs mr-xs flex-shrink-0 ring-inset ring-success-50 focus-outline-none":!0,"flex items-center justify-center rounded-full transition-colors":!0,"bg-contrast-5 text-disabled cursor-default":i,"bg-success-10 text-success cursor-pointer":!i,"hover-bg-success hover-text-success-contrast":!i,"focus-ring-2":!i}),i,r)}}export{b as E};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{T as t}from"./shared-
|
|
1
|
+
import{T as t}from"./shared-7e960a32.js";import{a as e}from"./shared-e82cc599.js";let s,n,a,o,l,i,r=t=>t;class c extends(e(t,"transactions-table")){constructor(){super(...arguments),this.columns=[c.priceColumn,c.summaryColumn,c.statusColumn,c.idColumn,c.dateColumn,c.receiptColumn]}}c.priceColumn={cell:t=>t.html(s||(s=r`
|
|
2
2
|
<foxy-i18n
|
|
3
3
|
data-testclass="i18n totals"
|
|
4
4
|
class="text-m font-semibold font-tnum"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PropertyDeclarations, TemplateResult } from 'lit-element';
|
|
2
|
+
import { LitElement } from 'lit-element';
|
|
2
3
|
import { NucleonElement } from '../../public/NucleonElement/NucleonElement';
|
|
3
4
|
declare const InternalControl_base: typeof LitElement & import("lit-element").Constructor<import("../../../mixins/inferrable").InferrableMixinHost> & {
|
|
4
5
|
inferredProperties: string[];
|
|
@@ -7,15 +8,34 @@ declare const InternalControl_base: typeof LitElement & import("lit-element").Co
|
|
|
7
8
|
} & import("lit-element").Constructor<import("../../../mixins/translatable").TranslatableMixinHost> & {
|
|
8
9
|
defaultNS: string;
|
|
9
10
|
} & import("lit-element").Constructor<import("../../../mixins/configurable").ConfigurableMixinHost>;
|
|
11
|
+
/**
|
|
12
|
+
* An internal base class for any control in a Nucleon form. That control can be as simple as a text field bound
|
|
13
|
+
* to a property or as complex as a query builder, and it infers property values from the
|
|
14
|
+
* parent Nucleon/Configurable/Translatable element, saving the need to manually calculate
|
|
15
|
+
* and bind properties in Lit templates. Each control renders before and after slots in the regular DOM + its
|
|
16
|
+
* own layout in the shadow DOM. When hidden via `hiddencontrols` in the parent,
|
|
17
|
+
* uses `display: none` to hide itself.
|
|
18
|
+
*
|
|
19
|
+
* @element foxy-internal-control
|
|
20
|
+
* @since 1.17.0
|
|
21
|
+
*/
|
|
10
22
|
export declare class InternalControl extends InternalControl_base {
|
|
11
23
|
static get inferredProperties(): string[];
|
|
12
24
|
static get properties(): PropertyDeclarations;
|
|
25
|
+
/** NucleonElement instance this control is bound to. */
|
|
13
26
|
nucleon: NucleonElement<any> | null;
|
|
14
|
-
infer: string;
|
|
15
27
|
inferFromElement(key: string, element: HTMLElement): unknown | undefined;
|
|
16
28
|
applyInferredProperties(context: Map<string, unknown>): void;
|
|
17
29
|
updated(changes: Map<keyof this, unknown>): void;
|
|
30
|
+
/**
|
|
31
|
+
* Renders the control itself. In most cases, you will need to implement
|
|
32
|
+
* this method instead of `.render()` in your class to keep the before and after templates/slots.
|
|
33
|
+
*/
|
|
18
34
|
renderControl(): TemplateResult;
|
|
35
|
+
/**
|
|
36
|
+
* Renders the control (if visible) and the before/after templates/slots.
|
|
37
|
+
* You should probably implement `.renderControl()` method instead of this one in your class.
|
|
38
|
+
*/
|
|
19
39
|
render(): TemplateResult;
|
|
20
40
|
}
|
|
21
41
|
export {};
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
import { html, LitElement } from 'lit-element';
|
|
2
|
-
import { render } from 'lit-html';
|
|
3
1
|
import { ConfigurableMixin } from "../../../mixins/configurable.js";
|
|
4
|
-
import { ThemeableMixin } from "../../../mixins/themeable.js";
|
|
5
2
|
import { TranslatableMixin } from "../../../mixins/translatable.js";
|
|
6
|
-
import {
|
|
3
|
+
import { html, LitElement } from 'lit-element';
|
|
7
4
|
import { InferrableMixin } from "../../../mixins/inferrable.js";
|
|
5
|
+
import { ThemeableMixin } from "../../../mixins/themeable.js";
|
|
6
|
+
import { NucleonElement } from "../../public/NucleonElement/NucleonElement.js";
|
|
7
|
+
import { render } from 'lit-html';
|
|
8
|
+
/**
|
|
9
|
+
* An internal base class for any control in a Nucleon form. That control can be as simple as a text field bound
|
|
10
|
+
* to a property or as complex as a query builder, and it infers property values from the
|
|
11
|
+
* parent Nucleon/Configurable/Translatable element, saving the need to manually calculate
|
|
12
|
+
* and bind properties in Lit templates. Each control renders before and after slots in the regular DOM + its
|
|
13
|
+
* own layout in the shadow DOM. When hidden via `hiddencontrols` in the parent,
|
|
14
|
+
* uses `display: none` to hide itself.
|
|
15
|
+
*
|
|
16
|
+
* @element foxy-internal-control
|
|
17
|
+
* @since 1.17.0
|
|
18
|
+
*/
|
|
8
19
|
export class InternalControl extends ConfigurableMixin(TranslatableMixin(ThemeableMixin(InferrableMixin(LitElement)))) {
|
|
9
20
|
constructor() {
|
|
10
21
|
super(...arguments);
|
|
22
|
+
/** NucleonElement instance this control is bound to. */
|
|
11
23
|
this.nucleon = null;
|
|
12
|
-
this.infer = '';
|
|
13
24
|
}
|
|
14
25
|
static get inferredProperties() {
|
|
15
26
|
return [...super.inferredProperties, 'nucleon'];
|
|
@@ -32,15 +43,25 @@ export class InternalControl extends ConfigurableMixin(TranslatableMixin(Themeab
|
|
|
32
43
|
}
|
|
33
44
|
updated(changes) {
|
|
34
45
|
super.updated(changes);
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
if (typeof this.infer === 'string') {
|
|
47
|
+
const lightDomTemplate = html `
|
|
37
48
|
<slot name="${this.infer}:before" slot="before"></slot>
|
|
38
49
|
<slot name="${this.infer}:after" slot="after"></slot>
|
|
39
|
-
|
|
50
|
+
`;
|
|
51
|
+
render(lightDomTemplate, this);
|
|
52
|
+
}
|
|
40
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Renders the control itself. In most cases, you will need to implement
|
|
56
|
+
* this method instead of `.render()` in your class to keep the before and after templates/slots.
|
|
57
|
+
*/
|
|
41
58
|
renderControl() {
|
|
42
59
|
return html ``;
|
|
43
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Renders the control (if visible) and the before/after templates/slots.
|
|
63
|
+
* You should probably implement `.renderControl()` method instead of this one in your class.
|
|
64
|
+
*/
|
|
44
65
|
render() {
|
|
45
66
|
if (this.hidden)
|
|
46
67
|
return html ``;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalControl/InternalControl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InternalControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalControl/InternalControl.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,cAAc,EAAE,sDAAmD;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAgB,SAAQ,iBAAiB,CACpD,iBAAiB,CAAC,cAAc,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,CAC/D;IAFD;;QAcE,wDAAwD;QACxD,YAAO,GAA+B,IAAI,CAAC;IA6C7C,CAAC;IAzDC,MAAM,KAAK,kBAAkB;QAC3B,OAAO,CAAC,GAAG,KAAK,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;SAC9B,CAAC;IACJ,CAAC;IAKD,gBAAgB,CAAC,GAAW,EAAE,OAAoB;QAChD,IAAI,GAAG,KAAK,SAAS,IAAI,OAAO,YAAY,cAAc;YAAE,OAAO,OAAO,CAAC;QAC3E,OAAO,KAAK,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,uBAAuB,CAAC,OAA6B;;QACnD,KAAK,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,SAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAqC,mCAAI,IAAI,CAAC;IACrF,CAAC;IAED,OAAO,CAAC,OAAiC;QACvC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEvB,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE;YAClC,MAAM,gBAAgB,GAAG,IAAI,CAAA;sBACb,IAAI,CAAC,KAAK;sBACV,IAAI,CAAC,KAAK;OACzB,CAAC;YAEF,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;SAChC;IACH,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,IAAI,CAAA,EAAE,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAA,EAAE,CAAC;QAE/B,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,aAAa,EAAE;QACzE,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC;KACnD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { html, LitElement } from 'lit-element';\nimport { InferrableMixin } from '../../../mixins/inferrable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { NucleonElement } from '../../public/NucleonElement/NucleonElement';\nimport { render } from 'lit-html';\n\n/**\n * An internal base class for any control in a Nucleon form. That control can be as simple as a text field bound\n * to a property or as complex as a query builder, and it infers property values from the\n * parent Nucleon/Configurable/Translatable element, saving the need to manually calculate\n * and bind properties in Lit templates. Each control renders before and after slots in the regular DOM + its\n * own layout in the shadow DOM. When hidden via `hiddencontrols` in the parent,\n * uses `display: none` to hide itself.\n *\n * @element foxy-internal-control\n * @since 1.17.0\n */\nexport class InternalControl extends ConfigurableMixin(\n TranslatableMixin(ThemeableMixin(InferrableMixin(LitElement)))\n) {\n static get inferredProperties(): string[] {\n return [...super.inferredProperties, 'nucleon'];\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n nucleon: { attribute: false },\n };\n }\n\n /** NucleonElement instance this control is bound to. */\n nucleon: NucleonElement<any> | null = null;\n\n inferFromElement(key: string, element: HTMLElement): unknown | undefined {\n if (key === 'nucleon' && element instanceof NucleonElement) return element;\n return super.inferFromElement(key, element);\n }\n\n applyInferredProperties(context: Map<string, unknown>): void {\n super.applyInferredProperties(context);\n this.nucleon = (context.get('nucleon') as NucleonElement<any> | undefined) ?? null;\n }\n\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n\n if (typeof this.infer === 'string') {\n const lightDomTemplate = html`\n <slot name=\"${this.infer}:before\" slot=\"before\"></slot>\n <slot name=\"${this.infer}:after\" slot=\"after\"></slot>\n `;\n\n render(lightDomTemplate, this);\n }\n }\n\n /**\n * Renders the control itself. In most cases, you will need to implement\n * this method instead of `.render()` in your class to keep the before and after templates/slots.\n */\n renderControl(): TemplateResult {\n return html``;\n }\n\n /**\n * Renders the control (if visible) and the before/after templates/slots.\n * You should probably implement `.renderControl()` method instead of this one in your class.\n */\n render(): TemplateResult {\n if (this.hidden) return html``;\n\n return html`\n ${this.renderTemplateOrSlot('before', this.nucleon)} ${this.renderControl()}\n ${this.renderTemplateOrSlot('after', this.nucleon)}\n `;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalControl/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,6BAA0B;AAEpD,cAAc,CAAC,MAAM,CAAC,uBAAuB,EAAE,eAAe,CAAC,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { InternalControl } from './InternalControl';\n\ncustomElements.define('foxy-internal-control', InternalControl);\n\nexport { InternalControl };\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalControl/index.ts"],"names":[],"mappings":"AAAA,qCAAkC;AAClC,oCAAiC;AAEjC,OAAO,EAAE,eAAe,EAAE,6BAA0B;AAEpD,cAAc,CAAC,MAAM,CAAC,uBAAuB,EAAE,eAAe,CAAC,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import '../InternalSandbox/index';\nimport '../../public/I18n/index';\n\nimport { InternalControl } from './InternalControl';\n\ncustomElements.define('foxy-internal-control', InternalControl);\n\nexport { InternalControl };\n"]}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { PropertyDeclarations } from 'lit-element';
|
|
2
2
|
import { InternalControl } from '../InternalControl/InternalControl';
|
|
3
|
+
/**
|
|
4
|
+
* An internal base class for controls that have editing functionality, e.g. a text field.
|
|
5
|
+
* Instances of this class will provide shortcuts for translatable placeholder, label, helper
|
|
6
|
+
* text and more. Unlike a regular control, editable control can not only read from a NucleonElement
|
|
7
|
+
* instance up the DOM tree, but also send changes to it and trigger validation process.
|
|
8
|
+
*
|
|
9
|
+
* @element foxy-internal-editable-control
|
|
10
|
+
* @since 1.17.0
|
|
11
|
+
*/
|
|
3
12
|
export declare class InternalEditableControl extends InternalControl {
|
|
4
13
|
static get properties(): PropertyDeclarations;
|
|
5
14
|
private __placeholder;
|
|
@@ -7,19 +16,62 @@ export declare class InternalEditableControl extends InternalControl {
|
|
|
7
16
|
private __v8nPrefix;
|
|
8
17
|
private __property;
|
|
9
18
|
private __label;
|
|
19
|
+
/**
|
|
20
|
+
* Translated placeholder text for this control. You can set your own placeholder text
|
|
21
|
+
* if the default key in the inferred namespace doesn't work for you. Use `.resetPlaceholder()`
|
|
22
|
+
* to restore the default translation.
|
|
23
|
+
*/
|
|
10
24
|
get placeholder(): string;
|
|
11
25
|
set placeholder(newValue: string);
|
|
26
|
+
/**
|
|
27
|
+
* Translated helper text for this control. You can set your own helper text
|
|
28
|
+
* if the default key in the inferred namespace doesn't work for you. Use `.resetHelperText()`
|
|
29
|
+
* to restore the default translation.
|
|
30
|
+
*/
|
|
12
31
|
get helperText(): string;
|
|
13
32
|
set helperText(newValue: string);
|
|
33
|
+
/**
|
|
34
|
+
* A prefix for all v8n errors related to this control. You can set your own v8n prefix
|
|
35
|
+
* if the default one doesn't work for you. Use `.resetV8nPrefix()`
|
|
36
|
+
* to restore the default v8n prefix.
|
|
37
|
+
*/
|
|
14
38
|
get v8nPrefix(): string;
|
|
15
39
|
set v8nPrefix(newValue: string);
|
|
40
|
+
/**
|
|
41
|
+
* Name of the property to bind to inferred from the control name by converting it to snake_case.
|
|
42
|
+
* You can set your own property name if the default inference method produces an incorrect result.
|
|
43
|
+
* Use `.resetProperty()` to restore the default property name.
|
|
44
|
+
*/
|
|
16
45
|
get property(): string;
|
|
17
46
|
set property(newValue: string);
|
|
47
|
+
/**
|
|
48
|
+
* Translated label for this control. You can set your own label if the default key in the inferred
|
|
49
|
+
* namespace doesn't work for you. Use `.resetLabel()` to restore the default translation.
|
|
50
|
+
*/
|
|
18
51
|
get label(): string;
|
|
19
52
|
set label(newValue: string);
|
|
53
|
+
/** Restores the default placeholder translation. */
|
|
54
|
+
resetPlaceholder(): void;
|
|
55
|
+
/** Restores the default helper text translation. */
|
|
56
|
+
resetHelperText(): void;
|
|
57
|
+
/** Restores the default v8n prefix for errors. */
|
|
58
|
+
resetV8nPrefix(): void;
|
|
59
|
+
/** Restores the default property name. */
|
|
60
|
+
resetProperty(): void;
|
|
61
|
+
/** Restores the default label translation. */
|
|
62
|
+
resetLabel(): void;
|
|
63
|
+
/**
|
|
64
|
+
* A shortcut to get the inferred value from the NucleonElement instance
|
|
65
|
+
* up the DOM tree. If no such value or instance exists, returns `undefined`.
|
|
66
|
+
* Assigning a value to this property will dispatch a cancelable `change` event
|
|
67
|
+
* with the new value in the detail and write changes to the NucleonElement instance if permitted.
|
|
68
|
+
*/
|
|
20
69
|
protected get _value(): unknown | undefined;
|
|
21
70
|
protected set _value(newValue: unknown | undefined);
|
|
71
|
+
/** A shortcut returning the first v8n error associated with this control. */
|
|
22
72
|
protected get _error(): string | undefined;
|
|
73
|
+
/** A shortcut returning the localized text of the first v8n error associated with this control. */
|
|
23
74
|
protected get _errorMessage(): string | undefined;
|
|
75
|
+
/** A helper returning a `.checkValidity()` function for use with Vaadin elements. */
|
|
24
76
|
protected get _checkValidity(): () => boolean;
|
|
25
77
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { InternalControl } from "../InternalControl/InternalControl.js";
|
|
2
|
+
/**
|
|
3
|
+
* An internal base class for controls that have editing functionality, e.g. a text field.
|
|
4
|
+
* Instances of this class will provide shortcuts for translatable placeholder, label, helper
|
|
5
|
+
* text and more. Unlike a regular control, editable control can not only read from a NucleonElement
|
|
6
|
+
* instance up the DOM tree, but also send changes to it and trigger validation process.
|
|
7
|
+
*
|
|
8
|
+
* @element foxy-internal-editable-control
|
|
9
|
+
* @since 1.17.0
|
|
10
|
+
*/
|
|
2
11
|
export class InternalEditableControl extends InternalControl {
|
|
3
12
|
constructor() {
|
|
4
13
|
super(...arguments);
|
|
@@ -11,11 +20,6 @@ export class InternalEditableControl extends InternalControl {
|
|
|
11
20
|
static get properties() {
|
|
12
21
|
return {
|
|
13
22
|
...super.properties,
|
|
14
|
-
__placeholder: { attribute: false },
|
|
15
|
-
__helperText: { attribute: false },
|
|
16
|
-
__v8nPrefix: { attribute: false },
|
|
17
|
-
__property: { attribute: false },
|
|
18
|
-
__label: { attribute: false },
|
|
19
23
|
placeholder: { type: String, noAccessor: true },
|
|
20
24
|
helperText: { type: String, attribute: 'helper-text', noAccessor: true },
|
|
21
25
|
v8nPrefix: { type: String, attribute: 'v8n-prefix', noAccessor: true },
|
|
@@ -23,36 +27,104 @@ export class InternalEditableControl extends InternalControl {
|
|
|
23
27
|
label: { type: String, noAccessor: true },
|
|
24
28
|
};
|
|
25
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Translated placeholder text for this control. You can set your own placeholder text
|
|
32
|
+
* if the default key in the inferred namespace doesn't work for you. Use `.resetPlaceholder()`
|
|
33
|
+
* to restore the default translation.
|
|
34
|
+
*/
|
|
26
35
|
get placeholder() {
|
|
27
36
|
return typeof this.__placeholder === 'string' ? this.__placeholder : this.t('placeholder');
|
|
28
37
|
}
|
|
29
38
|
set placeholder(newValue) {
|
|
39
|
+
this.requestUpdate('placeholder', this.__placeholder);
|
|
30
40
|
this.__placeholder = newValue;
|
|
31
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Translated helper text for this control. You can set your own helper text
|
|
44
|
+
* if the default key in the inferred namespace doesn't work for you. Use `.resetHelperText()`
|
|
45
|
+
* to restore the default translation.
|
|
46
|
+
*/
|
|
32
47
|
get helperText() {
|
|
33
48
|
return typeof this.__helperText === 'string' ? this.__helperText : this.t('helper_text');
|
|
34
49
|
}
|
|
35
50
|
set helperText(newValue) {
|
|
51
|
+
this.requestUpdate('helperText', this.__helperText);
|
|
36
52
|
this.__helperText = newValue;
|
|
37
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* A prefix for all v8n errors related to this control. You can set your own v8n prefix
|
|
56
|
+
* if the default one doesn't work for you. Use `.resetV8nPrefix()`
|
|
57
|
+
* to restore the default v8n prefix.
|
|
58
|
+
*/
|
|
38
59
|
get v8nPrefix() {
|
|
39
|
-
|
|
60
|
+
if (typeof this.__v8nPrefix === 'string')
|
|
61
|
+
return this.__v8nPrefix;
|
|
62
|
+
if (typeof this.infer === 'string')
|
|
63
|
+
return `${this.infer}:`;
|
|
64
|
+
return '';
|
|
40
65
|
}
|
|
41
66
|
set v8nPrefix(newValue) {
|
|
67
|
+
this.requestUpdate('v8nPrefix', this.__v8nPrefix);
|
|
42
68
|
this.__v8nPrefix = newValue;
|
|
43
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Name of the property to bind to inferred from the control name by converting it to snake_case.
|
|
72
|
+
* You can set your own property name if the default inference method produces an incorrect result.
|
|
73
|
+
* Use `.resetProperty()` to restore the default property name.
|
|
74
|
+
*/
|
|
44
75
|
get property() {
|
|
45
|
-
|
|
76
|
+
if (typeof this.__property === 'string')
|
|
77
|
+
return this.__property;
|
|
78
|
+
if (typeof this.infer === 'string')
|
|
79
|
+
return this.infer.replace(/-/g, '_');
|
|
80
|
+
return '';
|
|
46
81
|
}
|
|
47
82
|
set property(newValue) {
|
|
83
|
+
this.requestUpdate('property', this.__property);
|
|
48
84
|
this.__property = newValue;
|
|
49
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Translated label for this control. You can set your own label if the default key in the inferred
|
|
88
|
+
* namespace doesn't work for you. Use `.resetLabel()` to restore the default translation.
|
|
89
|
+
*/
|
|
50
90
|
get label() {
|
|
51
91
|
return typeof this.__label === 'string' ? this.__label : this.t('label');
|
|
52
92
|
}
|
|
53
93
|
set label(newValue) {
|
|
94
|
+
this.requestUpdate('label', this.__label);
|
|
54
95
|
this.__label = newValue;
|
|
55
96
|
}
|
|
97
|
+
/** Restores the default placeholder translation. */
|
|
98
|
+
resetPlaceholder() {
|
|
99
|
+
this.requestUpdate('placeholder', this.__placeholder);
|
|
100
|
+
this.__placeholder = null;
|
|
101
|
+
}
|
|
102
|
+
/** Restores the default helper text translation. */
|
|
103
|
+
resetHelperText() {
|
|
104
|
+
this.requestUpdate('helperText', this.__helperText);
|
|
105
|
+
this.__helperText = null;
|
|
106
|
+
}
|
|
107
|
+
/** Restores the default v8n prefix for errors. */
|
|
108
|
+
resetV8nPrefix() {
|
|
109
|
+
this.requestUpdate('v8nPrefix', this.__v8nPrefix);
|
|
110
|
+
this.__v8nPrefix = null;
|
|
111
|
+
}
|
|
112
|
+
/** Restores the default property name. */
|
|
113
|
+
resetProperty() {
|
|
114
|
+
this.requestUpdate('property', this.__property);
|
|
115
|
+
this.__property = null;
|
|
116
|
+
}
|
|
117
|
+
/** Restores the default label translation. */
|
|
118
|
+
resetLabel() {
|
|
119
|
+
this.requestUpdate('label', this.__label);
|
|
120
|
+
this.__label = null;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A shortcut to get the inferred value from the NucleonElement instance
|
|
124
|
+
* up the DOM tree. If no such value or instance exists, returns `undefined`.
|
|
125
|
+
* Assigning a value to this property will dispatch a cancelable `change` event
|
|
126
|
+
* with the new value in the detail and write changes to the NucleonElement instance if permitted.
|
|
127
|
+
*/
|
|
56
128
|
get _value() {
|
|
57
129
|
var _a;
|
|
58
130
|
return (_a = this.nucleon) === null || _a === void 0 ? void 0 : _a.form[this.property];
|
|
@@ -64,13 +136,16 @@ export class InternalEditableControl extends InternalControl {
|
|
|
64
136
|
if (useDefaultAction)
|
|
65
137
|
(_a = this.nucleon) === null || _a === void 0 ? void 0 : _a.edit({ [this.property]: newValue });
|
|
66
138
|
}
|
|
139
|
+
/** A shortcut returning the first v8n error associated with this control. */
|
|
67
140
|
get _error() {
|
|
68
141
|
var _a;
|
|
69
142
|
return (_a = this.nucleon) === null || _a === void 0 ? void 0 : _a.errors.find(v => v.startsWith(this.v8nPrefix));
|
|
70
143
|
}
|
|
144
|
+
/** A shortcut returning the localized text of the first v8n error associated with this control. */
|
|
71
145
|
get _errorMessage() {
|
|
72
146
|
return this._error ? this.t(this._error.substring(this.v8nPrefix.length)) : undefined;
|
|
73
147
|
}
|
|
148
|
+
/** A helper returning a `.checkValidity()` function for use with Vaadin elements. */
|
|
74
149
|
get _checkValidity() {
|
|
75
150
|
return () => !this._error;
|
|
76
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalEditableControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalEditableControl/InternalEditableControl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,8CAA2C;AAErE,MAAM,OAAO,uBAAwB,SAAQ,eAAe;IAA5D;;QAiBU,kBAAa,GAAkB,IAAI,CAAC;QAEpC,iBAAY,GAAkB,IAAI,CAAC;QAEnC,gBAAW,GAAkB,IAAI,CAAC;QAElC,eAAU,GAAkB,IAAI,CAAC;QAEjC,YAAO,GAAkB,IAAI,CAAC;IA+DxC,CAAC;IAvFC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,aAAa,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YACnC,YAAY,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YAClC,WAAW,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YACjC,UAAU,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YAChC,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YAC7B,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE;YAC/C,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE;YACxE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE;YACtE,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE;YAC5C,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE;SAC1C,CAAC;IACJ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,CAAC;IAC3E,CAAC;IAED,IAAI,KAAK,CAAC,QAAgB;QACxB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAED,IAAc,MAAM;;QAClB,aAAO,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;IAC3C,CAAC;IAED,IAAc,MAAM,CAAC,QAA6B;;QAChD,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChF,MAAM,gBAAgB,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,gBAAgB;YAAE,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,EAAE;IAC1E,CAAC;IAED,IAAc,MAAM;;QAClB,aAAO,IAAI,CAAC,OAAO,0CAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;IACtE,CAAC;IAED,IAAc,aAAa;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxF,CAAC;IAED,IAAc,cAAc;QAC1B,OAAO,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport { InternalControl } from '../InternalControl/InternalControl';\n\nexport class InternalEditableControl extends InternalControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __placeholder: { attribute: false },\n __helperText: { attribute: false },\n __v8nPrefix: { attribute: false },\n __property: { attribute: false },\n __label: { attribute: false },\n placeholder: { type: String, noAccessor: true },\n helperText: { type: String, attribute: 'helper-text', noAccessor: true },\n v8nPrefix: { type: String, attribute: 'v8n-prefix', noAccessor: true },\n property: { type: String, noAccessor: true },\n label: { type: String, noAccessor: true },\n };\n }\n\n private __placeholder: string | null = null;\n\n private __helperText: string | null = null;\n\n private __v8nPrefix: string | null = null;\n\n private __property: string | null = null;\n\n private __label: string | null = null;\n\n get placeholder(): string {\n return typeof this.__placeholder === 'string' ? this.__placeholder : this.t('placeholder');\n }\n\n set placeholder(newValue: string) {\n this.__placeholder = newValue;\n }\n\n get helperText(): string {\n return typeof this.__helperText === 'string' ? this.__helperText : this.t('helper_text');\n }\n\n set helperText(newValue: string) {\n this.__helperText = newValue;\n }\n\n get v8nPrefix(): string {\n return typeof this.__v8nPrefix === 'string' ? this.__v8nPrefix : `${this.infer}:`;\n }\n\n set v8nPrefix(newValue: string) {\n this.__v8nPrefix = newValue;\n }\n\n get property(): string {\n return typeof this.__property === 'string' ? this.__property : this.infer.replace(/-/g, '_');\n }\n\n set property(newValue: string) {\n this.__property = newValue;\n }\n\n get label(): string {\n return typeof this.__label === 'string' ? this.__label : this.t('label');\n }\n\n set label(newValue: string) {\n this.__label = newValue;\n }\n\n protected get _value(): unknown | undefined {\n return this.nucleon?.form[this.property];\n }\n\n protected set _value(newValue: unknown | undefined) {\n const event = new CustomEvent('change', { cancelable: true, detail: newValue });\n const useDefaultAction = this.dispatchEvent(event);\n if (useDefaultAction) this.nucleon?.edit({ [this.property]: newValue });\n }\n\n protected get _error(): string | undefined {\n return this.nucleon?.errors.find(v => v.startsWith(this.v8nPrefix));\n }\n\n protected get _errorMessage(): string | undefined {\n return this._error ? this.t(this._error.substring(this.v8nPrefix.length)) : undefined;\n }\n\n protected get _checkValidity(): () => boolean {\n return () => !this._error;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InternalEditableControl.js","sourceRoot":"","sources":["../../../../src/el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,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChF,MAAM,gBAAgB,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,gBAAgB;YAAE,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,EAAE;IAC1E,CAAC;IACD,6EAA6E;IAE7E,IAAc,MAAM;;QAClB,aAAO,IAAI,CAAC,OAAO,0CAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;IACtE,CAAC;IACD,mGAAmG;IAEnG,IAAc,aAAa;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxF,CAAC;IACD,qFAAqF;IAErF,IAAc,cAAc;QAC1B,OAAO,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport { InternalControl } from '../InternalControl/InternalControl';\n\n/**\n * An internal base class for controls that have editing functionality, e.g. a text field.\n * Instances of this class will provide shortcuts for translatable placeholder, label, helper\n * text and more. Unlike a regular control, editable control can not only read from a NucleonElement\n * instance up the DOM tree, but also send changes to it and trigger validation process.\n *\n * @element foxy-internal-editable-control\n * @since 1.17.0\n */\nexport class InternalEditableControl extends InternalControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n placeholder: { type: String, noAccessor: true },\n helperText: { type: String, attribute: 'helper-text', noAccessor: true },\n v8nPrefix: { type: String, attribute: 'v8n-prefix', noAccessor: true },\n property: { type: String, noAccessor: true },\n label: { type: String, noAccessor: true },\n };\n }\n\n private __placeholder: string | null = null;\n\n private __helperText: string | null = null;\n\n private __v8nPrefix: string | null = null;\n\n private __property: string | null = null;\n\n private __label: string | null = null;\n\n /**\n * Translated placeholder text for this control. You can set your own placeholder text\n * if the default key in the inferred namespace doesn't work for you. Use `.resetPlaceholder()`\n * to restore the default translation.\n */\n get placeholder(): string {\n return typeof this.__placeholder === 'string' ? this.__placeholder : this.t('placeholder');\n }\n\n set placeholder(newValue: string) {\n this.requestUpdate('placeholder', this.__placeholder);\n this.__placeholder = newValue;\n }\n\n /**\n * Translated helper text for this control. You can set your own helper text\n * if the default key in the inferred namespace doesn't work for you. Use `.resetHelperText()`\n * to restore the default translation.\n */\n get helperText(): string {\n return typeof this.__helperText === 'string' ? this.__helperText : this.t('helper_text');\n }\n\n set helperText(newValue: string) {\n this.requestUpdate('helperText', this.__helperText);\n this.__helperText = newValue;\n }\n\n /**\n * A prefix for all v8n errors related to this control. You can set your own v8n prefix\n * if the default one doesn't work for you. Use `.resetV8nPrefix()`\n * to restore the default v8n prefix.\n */\n get v8nPrefix(): string {\n if (typeof this.__v8nPrefix === 'string') return this.__v8nPrefix;\n if (typeof this.infer === 'string') return `${this.infer}:`;\n return '';\n }\n\n set v8nPrefix(newValue: string) {\n this.requestUpdate('v8nPrefix', this.__v8nPrefix);\n this.__v8nPrefix = newValue;\n }\n\n /**\n * Name of the property to bind to inferred from the control name by converting it to snake_case.\n * You can set your own property name if the default inference method produces an incorrect result.\n * Use `.resetProperty()` to restore the default property name.\n */\n get property(): string {\n if (typeof this.__property === 'string') return this.__property;\n if (typeof this.infer === 'string') return this.infer.replace(/-/g, '_');\n return '';\n }\n\n set property(newValue: string) {\n this.requestUpdate('property', this.__property);\n this.__property = newValue;\n }\n\n /**\n * Translated label for this control. You can set your own label if the default key in the inferred\n * namespace doesn't work for you. Use `.resetLabel()` to restore the default translation.\n */\n get label(): string {\n return typeof this.__label === 'string' ? this.__label : this.t('label');\n }\n\n set label(newValue: string) {\n this.requestUpdate('label', this.__label);\n this.__label = newValue;\n }\n\n /** Restores the default placeholder translation. */\n resetPlaceholder(): void {\n this.requestUpdate('placeholder', this.__placeholder);\n this.__placeholder = null;\n }\n\n /** Restores the default helper text translation. */\n resetHelperText(): void {\n this.requestUpdate('helperText', this.__helperText);\n this.__helperText = null;\n }\n\n /** Restores the default v8n prefix for errors. */\n resetV8nPrefix(): void {\n this.requestUpdate('v8nPrefix', this.__v8nPrefix);\n this.__v8nPrefix = null;\n }\n\n /** Restores the default property name. */\n resetProperty(): void {\n this.requestUpdate('property', this.__property);\n this.__property = null;\n }\n\n /** Restores the default label translation. */\n resetLabel(): void {\n this.requestUpdate('label', this.__label);\n this.__label = null;\n }\n\n /**\n * A shortcut to get the inferred value from the NucleonElement instance\n * up the DOM tree. If no such value or instance exists, returns `undefined`.\n * Assigning a value to this property will dispatch a cancelable `change` event\n * with the new value in the detail and write changes to the NucleonElement instance if permitted.\n */\n\n protected get _value(): unknown | undefined {\n return this.nucleon?.form[this.property];\n }\n\n protected set _value(newValue: unknown | undefined) {\n const event = new CustomEvent('change', { cancelable: true, detail: newValue });\n const useDefaultAction = this.dispatchEvent(event);\n if (useDefaultAction) this.nucleon?.edit({ [this.property]: newValue });\n }\n /** A shortcut returning the first v8n error associated with this control. */\n\n protected get _error(): string | undefined {\n return this.nucleon?.errors.find(v => v.startsWith(this.v8nPrefix));\n }\n /** A shortcut returning the localized text of the first v8n error associated with this control. */\n\n protected get _errorMessage(): string | undefined {\n return this._error ? this.t(this._error.substring(this.v8nPrefix.length)) : undefined;\n }\n /** A helper returning a `.checkValidity()` function for use with Vaadin elements. */\n\n protected get _checkValidity(): () => boolean {\n return () => !this._error;\n }\n}\n"]}
|
|
@@ -4,8 +4,24 @@ import { NucleonElement } from '../../public/NucleonElement/NucleonElement';
|
|
|
4
4
|
declare const Base: typeof NucleonElement & {
|
|
5
5
|
styles: import("lit-element").CSSResultArray;
|
|
6
6
|
} & import("lit-element").Constructor<import("../../../mixins/configurable").ConfigurableMixinHost>;
|
|
7
|
+
/**
|
|
8
|
+
* An internal base class for any nucleon-powered form. Renders create/delete
|
|
9
|
+
* buttons and timestamps by default, displays a spinner in non-idle states.
|
|
10
|
+
*
|
|
11
|
+
* @element foxy-internal-form
|
|
12
|
+
* @since 1.17.0
|
|
13
|
+
*/
|
|
7
14
|
export declare class InternalForm<TData extends HALJSONResource> extends Base<TData> {
|
|
15
|
+
/**
|
|
16
|
+
* Renders form body. This is the method you should implement in your forms
|
|
17
|
+
* instead of `.render()`. If you'd like to keep the submit button and the timestamps,
|
|
18
|
+
* don't forget to add `super.renderBody()` to your template.
|
|
19
|
+
*/
|
|
8
20
|
renderBody(): TemplateResult;
|
|
21
|
+
/**
|
|
22
|
+
* Renders the entire form. You should probably implement `.renderBody()`
|
|
23
|
+
* instead of this method in your form to keep the spinner and the common layout features.
|
|
24
|
+
*/
|
|
9
25
|
render(): TemplateResult;
|
|
10
26
|
}
|
|
11
27
|
export {};
|
|
@@ -4,7 +4,19 @@ import { NucleonElement } from "../../public/NucleonElement/NucleonElement.js";
|
|
|
4
4
|
import { classMap } from "../../../utils/class-map.js";
|
|
5
5
|
import { html } from 'lit-html';
|
|
6
6
|
const Base = ConfigurableMixin(ThemeableMixin(NucleonElement));
|
|
7
|
+
/**
|
|
8
|
+
* An internal base class for any nucleon-powered form. Renders create/delete
|
|
9
|
+
* buttons and timestamps by default, displays a spinner in non-idle states.
|
|
10
|
+
*
|
|
11
|
+
* @element foxy-internal-form
|
|
12
|
+
* @since 1.17.0
|
|
13
|
+
*/
|
|
7
14
|
export class InternalForm extends Base {
|
|
15
|
+
/**
|
|
16
|
+
* Renders form body. This is the method you should implement in your forms
|
|
17
|
+
* instead of `.render()`. If you'd like to keep the submit button and the timestamps,
|
|
18
|
+
* don't forget to add `super.renderBody()` to your template.
|
|
19
|
+
*/
|
|
8
20
|
renderBody() {
|
|
9
21
|
return this.data
|
|
10
22
|
? html `
|
|
@@ -13,6 +25,10 @@ export class InternalForm extends Base {
|
|
|
13
25
|
`
|
|
14
26
|
: html `<foxy-internal-create-control infer="create"></foxy-internal-create-control>`;
|
|
15
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Renders the entire form. You should probably implement `.renderBody()`
|
|
30
|
+
* instead of this method in your form to keep the spinner and the common layout features.
|
|
31
|
+
*/
|
|
16
32
|
render() {
|
|
17
33
|
const isSpinnerVisible = !this.in('idle') && (!this.in({ busy: 'fetching' }) || !this.data);
|
|
18
34
|
return html `
|
|
@@ -28,6 +44,7 @@ export class InternalForm extends Base {
|
|
|
28
44
|
</div>
|
|
29
45
|
|
|
30
46
|
<div
|
|
47
|
+
data-testid="spinner"
|
|
31
48
|
class=${classMap({
|
|
32
49
|
'transition-opacity absolute inset-0 flex': true,
|
|
33
50
|
'opacity-0 pointer-events-none': !isSpinnerVisible,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalForm.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalForm/InternalForm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,cAAc,EAAE,sDAAmD;AAC5E,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,IAAI,GAAG,iBAAiB,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC;AAE/D,MAAM,OAAO,YAA4C,SAAQ,IAAW;IAC1E,UAAU;QACR,OAAO,IAAI,CAAC,IAAI;YACd,CAAC,CAAC,IAAI,CAAA;;;SAGH;YACH,CAAC,CAAC,IAAI,CAAA,8EAA8E,CAAC;IACzF,CAAC;IAED,MAAM;QACJ,MAAM,gBAAgB,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,C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9B,oBAAoB,EAAE,IAAI;YAC1B,+BAA+B,EAAE,gBAAgB;SAClD,CAAC;;YAEA,IAAI,CAAC,UAAU,EAAE;;;;;kBAKX,QAAQ,CAAC;YACf,0CAA0C,EAAE,IAAI;YAChD,+BAA+B,EAAE,CAAC,gBAAgB;SACnD,CAAC;;;qBAGS,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU;;oBAE1C,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;;;;;;KAMjD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { HALJSONResource } from '../../public/NucleonElement/types';\nimport type { TemplateResult } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { NucleonElement } from '../../public/NucleonElement/NucleonElement';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-html';\n\nconst Base = ConfigurableMixin(ThemeableMixin(NucleonElement));\n\n/**\n * An internal base class for any nucleon-powered form. Renders create/delete\n * buttons and timestamps by default, displays a spinner in non-idle states.\n *\n * @element foxy-internal-form\n * @since 1.17.0\n */\nexport class InternalForm<TData extends HALJSONResource> extends Base<TData> {\n /**\n * Renders form body. This is the method you should implement in your forms\n * instead of `.render()`. If you'd like to keep the submit button and the timestamps,\n * don't forget to add `super.renderBody()` to your template.\n */\n renderBody(): TemplateResult {\n return this.data\n ? html`\n <foxy-internal-timestamps-control infer=\"timestamps\"></foxy-internal-timestamps-control>\n <foxy-internal-delete-control infer=\"delete\"></foxy-internal-delete-control>\n `\n : html`<foxy-internal-create-control infer=\"create\"></foxy-internal-create-control>`;\n }\n\n /**\n * Renders the entire form. You should probably implement `.renderBody()`\n * instead of this method in your form to keep the spinner and the common layout features.\n */\n render(): TemplateResult {\n const isSpinnerVisible = !this.in('idle') && (!this.in({ busy: 'fetching' }) || !this.data);\n\n return html`\n <div aria-busy=${this.in('busy')} aria-live=\"polite\" class=\"relative\">\n <div\n class=${classMap({\n 'grid grid-cols-1 gap-m': true,\n 'transition-opacity': true,\n 'opacity-0 pointer-events-none': isSpinnerVisible,\n })}\n >\n ${this.renderBody()}\n </div>\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'transition-opacity absolute inset-0 flex': true,\n 'opacity-0 pointer-events-none': !isSpinnerVisible,\n })}\n >\n <foxy-spinner\n layout=${this.in('fail') ? 'vertical' : 'no-label'}\n class=\"m-auto\"\n state=${this.in('fail') ? 'error' : 'busy'}\n infer=\"spinner\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import '../InternalTimestampsControl/index';
|
|
2
2
|
import '../InternalCreateControl/index';
|
|
3
3
|
import '../InternalDeleteControl/index';
|
|
4
|
-
import '
|
|
4
|
+
import '../../public/Spinner/index';
|
|
5
5
|
import { InternalForm } from './InternalForm';
|
|
6
6
|
export { InternalForm };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../InternalTimestampsControl/index.js";
|
|
2
2
|
import "../InternalCreateControl/index.js";
|
|
3
3
|
import "../InternalDeleteControl/index.js";
|
|
4
|
-
import "
|
|
4
|
+
import "../../public/Spinner/index.js";
|
|
5
5
|
import { InternalForm } from "./InternalForm.js";
|
|
6
6
|
customElements.define('foxy-internal-form', InternalForm);
|
|
7
7
|
export { InternalForm };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalForm/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalForm/index.ts"],"names":[],"mappings":"AAAA,+CAA4C;AAC5C,2CAAwC;AACxC,2CAAwC;AAExC,uCAAoC;AAEpC,OAAO,EAAE,YAAY,EAAE,0BAAuB;AAE9C,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import '../InternalTimestampsControl/index';\nimport '../InternalCreateControl/index';\nimport '../InternalDeleteControl/index';\n\nimport '../../public/Spinner/index';\n\nimport { InternalForm } from './InternalForm';\n\ncustomElements.define('foxy-internal-form', InternalForm);\n\nexport { InternalForm };\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CSSResultArray } from 'lit-element';
|
|
2
|
+
import { TemplateResult } from 'lit-html';
|
|
3
|
+
import { InternalControl } from '../InternalControl/InternalControl';
|
|
4
|
+
/**
|
|
5
|
+
* Internal control displaying creation and last modification date
|
|
6
|
+
* for a hAPI resource in a table.
|
|
7
|
+
*
|
|
8
|
+
* @element foxy-internal-timestamps-control
|
|
9
|
+
* @since 1.17.0
|
|
10
|
+
*/
|
|
11
|
+
export declare class InternalTimestampsControl extends InternalControl {
|
|
12
|
+
static get styles(): CSSResultArray;
|
|
13
|
+
renderControl(): TemplateResult;
|
|
14
|
+
}
|