@aceshooting/lyra-ui 8.1.0 → 8.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/custom-elements.json +1 -1
- package/dist/components/agent-tools/tool-param-form/tool-param-form.class.d.ts +5 -0
- package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +1 -1
- package/dist/components/charts/chart/chart.class.js +1 -1
- package/dist/components/conversation/chat-composer/chat-composer.class.js +1 -1
- package/dist/components/conversation/model-select/model-select.class.js +1 -1
- package/dist/components/conversation/voice-picker/voice-picker.class.js +1 -1
- package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +4 -0
- package/dist/components/data/graph-query-builder/graph-query-builder.class.js +1 -1
- package/dist/components/forms/checkbox/checkbox.class.js +1 -1
- package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +3 -0
- package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
- package/dist/components/forms/code-editor/code-editor.class.js +1 -1
- package/dist/components/forms/combobox/combobox.class.js +1 -1
- package/dist/components/forms/date-picker/date-input.class.js +1 -1
- package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
- package/dist/components/forms/input/input.class.js +1 -1
- package/dist/components/forms/input/time-input.class.js +1 -1
- package/dist/components/forms/locale-picker/locale-picker.class.js +1 -1
- package/dist/components/forms/otp-input/otp-input.class.js +1 -1
- package/dist/components/forms/phone-input/phone-input.class.js +1 -1
- package/dist/components/forms/radio/radio-group.class.d.ts +3 -0
- package/dist/components/forms/radio/radio-group.class.js +1 -1
- package/dist/components/forms/rubric-form/rubric-form.class.d.ts +3 -0
- package/dist/components/forms/rubric-form/rubric-form.class.js +1 -1
- package/dist/components/forms/select/select.class.js +1 -1
- package/dist/components/forms/switch/switch.class.js +1 -1
- package/dist/components/forms/textarea/textarea.class.js +1 -1
- package/dist/components/forms/token-input/token-input.class.js +1 -1
- package/dist/components/media/file-input/file-input.class.js +1 -1
- package/dist/components/utility/known-date/known-date.class.js +1 -1
- package/dist/internal/form-associated.js +1 -1
- package/dist/internal/localization-runtime.d.ts +13 -0
- package/dist/internal/localization-runtime.js +1 -1
- package/dist/internal/lyra-element.d.ts +15 -0
- package/dist/internal/lyra-element.js +1 -1
- package/dist/internal/package-metadata.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/testing/happy-dom-shims.d.ts +1 -1
- package/dist/testing/happy-dom-shims.js +1 -1
- package/llms/components/lr-checkbox-group.md +2 -0
- package/llms/components/lr-graph-query-builder.md +3 -1
- package/llms/components/lr-radio-group.md +3 -1
- package/llms/components/lr-rubric-form.md +2 -0
- package/llms/components/lr-tool-param-form.md +3 -0
- package/llms/peers.md +1 -1
- package/llms-full.txt +13 -2
- package/package.json +4 -4
- package/web-types.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LYRA_DEFAULT_fieldRequired}from"./default-strings.generated.js";import{resolveLyraString}from"./localization-runtime.js";import{AnchoredValidityController,SET_ANCHORED_VALIDITY,VALIDITY_ANCHOR}from"./anchored-validity.js";import{syncValidityStates}from"./custom-states.js";import{installInvalidEventAlias}from"./invalid-event-alias.js";import{omittedEmptyStringConverter}from"./converters.js";const FORM_ASSOCIATED_DEFAULT_STRINGS=Object.freeze({fieldRequired:LYRA_DEFAULT_fieldRequired});function setFormOwner(host,owner){const id=typeof owner==="string"?owner:owner?.id??"";if(id)host.setAttribute("form",id);else host.removeAttribute("form")}function getFormOwner(internals){return internals.form}function createStringArrayFormDataState(name,values){const state=new FormData;const key=name||"value";for(const value of values)state.append(key,value);return state}function readStringArrayFormDataState(state){if(typeof FormData!=="function")return[];let entries;try{entries=[...FormData.prototype.values.call(state)]}catch{return[]}if(entries.some(entry=>typeof entry!=="string"))return[];return entries}function isEmptyFormValue(value){if(value==null)return true;if(typeof value==="string")return value==="";if(Array.isArray(value))return value.length===0;if(typeof value==="object"){const prototype=Object.getPrototypeOf(value);if(prototype===null)return Object.keys(value).length===0;if(Object.getPrototypeOf(prototype)===null){const constructor=Object.getOwnPropertyDescriptor(prototype,"constructor")?.value;if(typeof constructor==="function"&&constructor.name==="Object"&&constructor.prototype===prototype){return Object.keys(value).length===0}}}return false}const stringFormValueAdapter={empty:"",toFormValue:value=>value,isEmpty:value=>value==="",fromAttribute:attribute=>attribute,toAttribute:value=>value,fromFormState:state=>typeof state==="string"?state:""};function resolveFormValueAdapter(adapter){if(adapter===void 0){return stringFormValueAdapter}return{empty:adapter.empty,toFormValue:value=>adapter.toFormValue(value),...adapter.toFormState?{toFormState:value=>adapter.toFormState(value)}:{},isEmpty:adapter.isEmpty?value=>adapter.isEmpty(value):isEmptyFormValue,fromAttribute:adapter.fromAttribute?attribute=>adapter.fromAttribute(attribute):attribute=>attribute,toAttribute:adapter.toAttribute?value=>adapter.toAttribute(value):value=>value==null?null:String(value),fromFormState:adapter.fromFormState?state=>adapter.fromFormState(state):state=>typeof state==="string"?state:adapter.empty}}function isBarredFromValidation(host,internals){if(host.effectiveDisabled??host.disabled)return true;if(host.readonly)return true;if(internals){const willValidate=readNativeWillValidate(internals);if(willValidate!==void 0)return!willValidate}return false}function readNativeWillValidate(internals){if(typeof ElementInternals!=="function")return void 0;const getter=Object.getOwnPropertyDescriptor(ElementInternals.prototype,"willValidate")?.get;if(typeof getter!=="function")return void 0;try{const value=getter.call(internals);return typeof value==="boolean"?value:void 0}catch{return void 0}}function installCustomErrorProperty(host,getCustomValidityMessage){if(Object.prototype.hasOwnProperty.call(host,"customError"))return;let reflecting=false;Object.defineProperty(host,"customError",{configurable:true,enumerable:true,get:()=>getCustomValidityMessage()||null,set:next=>{if(reflecting)return;const old=getCustomValidityMessage()||null;const message=next??"";reflecting=true;try{if(next==null){if(host.hasAttribute("custom-error"))host.removeAttribute("custom-error")}else if(host.getAttribute("custom-error")!==message){host.setAttribute("custom-error",message)}}finally{reflecting=false}host.setCustomValidity(message);host.requestUpdate("customError",old)}})}function createFallbackInternals(){let flags={};let message="";const validity={};const validityKeys=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"];for(const key of validityKeys){Object.defineProperty(validity,key,{enumerable:true,get:()=>Boolean(flags[key])})}Object.defineProperty(validity,"valid",{enumerable:true,get:()=>validityKeys.every(key=>!flags[key])});const states=new Set;return{form:null,labels:[],validity,get validationMessage(){return message},willValidate:false,states,setFormValue(){},setValidity(next={},nextMessage=""){flags={...next};message=nextMessage},checkValidity(){return validity.valid},reportValidity(){return validity.valid}}}function attachInternalsSafely(host){if(typeof host.attachInternals!=="function")return createFallbackInternals();try{return host.attachInternals()??createFallbackInternals()}catch{return createFallbackInternals()}}function FormAssociated(Base,valueAdapter){const adapter=resolveFormValueAdapter(valueAdapter);const defaultValueConverter={fromAttribute:attribute=>attribute===null?null:adapter.fromAttribute(attribute),toAttribute:value=>value==null?null:adapter.toAttribute(value)};class FormAssociatedElement extends Base{static{this.formAssociated=true}static{this.properties={name:{reflect:true,noAccessor:true,converter:omittedEmptyStringConverter},value:{attribute:false,noAccessor:true},defaultValue:{attribute:"value",reflect:true,useDefault:true,noAccessor:true,...valueAdapter?{converter:defaultValueConverter}:{}},customError:{attribute:"custom-error",reflect:true,noAccessor:true},form:{noAccessor:true},disabled:{type:Boolean,reflect:true,noAccessor:true},required:{type:Boolean,reflect:true,noAccessor:true}}}constructor(...args){super(...args);this._fieldsetDisabled=false;this._disabled=false;this._name="";this._value=adapter.empty;this._defaultValue=adapter.empty;this._valueDirty=false;this.settingDefaultValue=false;this.reflectingDefaultValue=false;this.reflectingCustomError=false;this.reflectingFormOwner=false;this._required=false;this._hasInteracted=false;this.internals=attachInternalsSafely(this);this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]());this.commitFormValue(this._value);installInvalidEventAlias(this,init=>this.emit("lr-invalid",void 0,init));const markInteracted=()=>{if(this._hasInteracted)return;this._hasInteracted=true;this.syncValidityStates()};this.addEventListener("input",markInteracted);this.addEventListener("change",markInteracted);this.addEventListener("focusout",markInteracted);this.syncValidityStates()}get form(){return getFormOwner(this.internals)}set form(owner){if(this.reflectingFormOwner)return;this.reflectingFormOwner=true;try{setFormOwner(this,owner)}finally{this.reflectingFormOwner=false}}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}[VALIDITY_ANCHOR](){return this.renderRoot?.querySelector("input:not([type='hidden']), textarea, select, button, [tabindex]:not([tabindex='-1'])")??null}[SET_ANCHORED_VALIDITY](flags,message=""){this.validityController.setValidity(flags,message);this.syncValidityStates()}setCustomValidity(message){this.validityController.setCustomValidity(message??"");this.syncValidityStates()}resetValidity(){this.validityController.setCustomValidity("");this.updateValidity();this.syncValidityStates()}syncValidityStates(){syncValidityStates(this.internals,{required:this.required,hasInteracted:this._hasInteracted,barred:this.isBarredFromValidation()})}isBarredFromValidation(){return isBarredFromValidation(this,this.internals)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"";if(this._name){this.setAttribute("name",this._name)}else{this.removeAttribute("name")}this.requestUpdate("name",old)}commitFormValue(value){const submitted=adapter.toFormValue(value);if(adapter.toFormState)this.internals.setFormValue(submitted,adapter.toFormState(value));else this.internals.setFormValue(submitted)}get value(){return this._value}set value(next){const old=this._value;this._value=next??adapter.empty;if(!this.settingDefaultValue)this._valueDirty=true;this.commitFormValue(this._value);this.updateValidity();this.requestUpdate("value",old)}get defaultValue(){return this._defaultValue}set defaultValue(next){if(this.reflectingDefaultValue)return;const old=this._defaultValue;this._defaultValue=next??adapter.empty;this.reflectingDefaultValue=true;try{const attribute=next==null?null:adapter.toAttribute(this._defaultValue);if(attribute==null)this.removeAttribute("value");else this.setAttribute("value",attribute)}finally{this.reflectingDefaultValue=false}if(!this._valueDirty)this.restoreLiveValueFromDefault();this.requestUpdate("defaultValue",old)}get customError(){return this.validityController.customValidityMessage||null}set customError(next){if(this.reflectingCustomError)return;const old=this.customError;const message=next??"";this.reflectingCustomError=true;try{if(next==null)this.removeAttribute("custom-error");else this.setAttribute("custom-error",message)}finally{this.reflectingCustomError=false}this.setCustomValidity(message);this.requestUpdate("customError",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=Boolean(next);this.toggleAttribute("disabled",this._disabled);this.updateValidity();this.syncValidityStates();this.requestUpdate("disabled",old)}get required(){return this._required}set required(next){const old=this._required;this._required=next;this.toggleAttribute("required",next);this.updateValidity();this.syncValidityStates();this.requestUpdate("required",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}setFormValue(next){this.value=next}updateValidity(){if(this.isBarredFromValidation()){this[SET_ANCHORED_VALIDITY]({});return}if(this.required&&adapter.isEmpty(this._value)){const overrides=this.strings;const message=resolveLyraString(this,"fieldRequired",overrides,void 0,void 0,FORM_ASSOCIATED_DEFAULT_STRINGS);this[SET_ANCHORED_VALIDITY]({valueMissing:true},message)}else{this[SET_ANCHORED_VALIDITY]({})}}syncConstraintsToNative(){const host=this;if(!host.hasUpdated)return;host.performUpdate()}checkValidity(){this.syncConstraintsToNative();this.updateValidity();return this.internals.checkValidity()}reportValidity(){this.syncConstraintsToNative();this.updateValidity();this._hasInteracted=true;this.syncValidityStates();return this.internals.reportValidity()}formResetCallback(){this._valueDirty=false;this.restoreLiveValueFromDefault();this._hasInteracted=false;this.syncValidityStates()}restoreLiveValueFromDefault(){this.settingDefaultValue=true;try{this.value=this._defaultValue}finally{this.settingDefaultValue=false}this._valueDirty=false}formStateRestoreCallback(state,reason){void reason;this.value=adapter.fromFormState(state)}formDisabledCallback(fieldsetDisabled){this._fieldsetDisabled=fieldsetDisabled;this.updateValidity();this.syncValidityStates();this.requestUpdate()}updated(changed){super.updated(changed);if(!changed.has("readonly")&&!changed.has("disabled"))return;this.updateValidity();this.syncValidityStates()}connectedCallback(){super.connectedCallback();this.updateValidity();this.syncValidityStates()}}return FormAssociatedElement}export{FormAssociated,attachInternalsSafely,createFallbackInternals,createStringArrayFormDataState,getFormOwner,installCustomErrorProperty,isBarredFromValidation,isEmptyFormValue,readStringArrayFormDataState,setFormOwner,stringFormValueAdapter};
|
|
1
|
+
import{LYRA_DEFAULT_fieldRequired}from"./default-strings.generated.js";import{resolveLyraString}from"./localization-runtime.js";import{AnchoredValidityController,SET_ANCHORED_VALIDITY,VALIDITY_ANCHOR}from"./anchored-validity.js";import{syncValidityStates}from"./custom-states.js";import{installInvalidEventAlias}from"./invalid-event-alias.js";import{omittedEmptyStringConverter}from"./converters.js";const FORM_ASSOCIATED_DEFAULT_STRINGS=Object.freeze({fieldRequired:LYRA_DEFAULT_fieldRequired});function setFormOwner(host,owner){const id=typeof owner==="string"?owner:owner?.id??"";if(id)host.setAttribute("form",id);else host.removeAttribute("form")}function getFormOwner(internals){return internals.form}function createStringArrayFormDataState(name,values){const state=new FormData;const key=name||"value";for(const value of values)state.append(key,value);return state}function readStringArrayFormDataState(state){if(typeof FormData!=="function")return[];let entries;try{entries=[...FormData.prototype.values.call(state)]}catch{return[]}if(entries.some(entry=>typeof entry!=="string"))return[];return entries}function isEmptyFormValue(value){if(value==null)return true;if(typeof value==="string")return value==="";if(Array.isArray(value))return value.length===0;if(typeof value==="object"){const prototype=Object.getPrototypeOf(value);if(prototype===null)return Object.keys(value).length===0;if(Object.getPrototypeOf(prototype)===null){const constructor=Object.getOwnPropertyDescriptor(prototype,"constructor")?.value;if(typeof constructor==="function"&&constructor.name==="Object"&&constructor.prototype===prototype){return Object.keys(value).length===0}}}return false}const stringFormValueAdapter={empty:"",toFormValue:value=>value,isEmpty:value=>value==="",fromAttribute:attribute=>attribute,toAttribute:value=>value,fromFormState:state=>typeof state==="string"?state:""};function resolveFormValueAdapter(adapter){if(adapter===void 0){return stringFormValueAdapter}return{empty:adapter.empty,toFormValue:value=>adapter.toFormValue(value),...adapter.toFormState?{toFormState:value=>adapter.toFormState(value)}:{},isEmpty:adapter.isEmpty?value=>adapter.isEmpty(value):isEmptyFormValue,fromAttribute:adapter.fromAttribute?attribute=>adapter.fromAttribute(attribute):attribute=>attribute,toAttribute:adapter.toAttribute?value=>adapter.toAttribute(value):value=>value==null?null:String(value),fromFormState:adapter.fromFormState?state=>adapter.fromFormState(state):state=>typeof state==="string"?state:adapter.empty}}function isBarredFromValidation(host,internals){if(host.effectiveDisabled??host.disabled)return true;if(host.readonly)return true;if(internals){const willValidate=readNativeWillValidate(internals);if(willValidate!==void 0)return!willValidate}return false}function readNativeWillValidate(internals){if(typeof ElementInternals!=="function")return void 0;const getter=Object.getOwnPropertyDescriptor(ElementInternals.prototype,"willValidate")?.get;if(typeof getter!=="function")return void 0;try{const value=getter.call(internals);return typeof value==="boolean"?value:void 0}catch{return void 0}}function installCustomErrorProperty(host,getCustomValidityMessage){if(Object.prototype.hasOwnProperty.call(host,"customError"))return;let reflecting=false;Object.defineProperty(host,"customError",{configurable:true,enumerable:true,get:()=>getCustomValidityMessage()||null,set:next=>{if(reflecting)return;const old=getCustomValidityMessage()||null;const message=next??"";reflecting=true;try{if(next==null){if(host.hasAttribute("custom-error"))host.removeAttribute("custom-error")}else if(host.getAttribute("custom-error")!==message){host.setAttribute("custom-error",message)}}finally{reflecting=false}host.setCustomValidity(message);host.requestUpdate("customError",old)}})}function createFallbackInternals(){let flags={};let message="";const validity={};const validityKeys=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"];for(const key of validityKeys){Object.defineProperty(validity,key,{enumerable:true,get:()=>Boolean(flags[key])})}Object.defineProperty(validity,"valid",{enumerable:true,get:()=>validityKeys.every(key=>!flags[key])});const states=new Set;return{form:null,labels:[],validity,get validationMessage(){return message},willValidate:false,states,setFormValue(){},setValidity(next={},nextMessage=""){flags={...next};message=nextMessage},checkValidity(){return validity.valid},reportValidity(){return validity.valid}}}function attachInternalsSafely(host){if(typeof host.attachInternals!=="function")return createFallbackInternals();try{return host.attachInternals()??createFallbackInternals()}catch{return createFallbackInternals()}}function FormAssociated(Base,valueAdapter){const adapter=resolveFormValueAdapter(valueAdapter);const defaultValueConverter={fromAttribute:attribute=>attribute===null?null:adapter.fromAttribute(attribute),toAttribute:value=>value==null?null:adapter.toAttribute(value)};class FormAssociatedElement extends Base{static{this.formAssociated=true}static{this.properties={name:{reflect:true,noAccessor:true,converter:omittedEmptyStringConverter},value:{attribute:false,noAccessor:true},defaultValue:{attribute:"value",reflect:true,useDefault:true,noAccessor:true,...valueAdapter?{converter:defaultValueConverter}:{}},customError:{attribute:"custom-error",reflect:true,noAccessor:true},form:{noAccessor:true},disabled:{type:Boolean,reflect:true,noAccessor:true},required:{type:Boolean,reflect:true,noAccessor:true}}}constructor(...args){super(...args);this._fieldsetDisabled=false;this._disabled=false;this._reflectingDisabledAttribute=false;this._name="";this._value=adapter.empty;this._defaultValue=adapter.empty;this._valueDirty=false;this.settingDefaultValue=false;this.reflectingDefaultValue=false;this.reflectingCustomError=false;this.reflectingFormOwner=false;this._required=false;this._hasInteracted=false;this.internals=attachInternalsSafely(this);this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]());this.commitFormValue(this._value);installInvalidEventAlias(this,init=>this.emit("lr-invalid",void 0,init));const markInteracted=()=>{if(this._hasInteracted)return;this._hasInteracted=true;this.syncValidityStates()};this.addEventListener("input",markInteracted);this.addEventListener("change",markInteracted);this.addEventListener("focusout",markInteracted);this.syncValidityStates()}get form(){return getFormOwner(this.internals)}set form(owner){if(this.reflectingFormOwner)return;this.reflectingFormOwner=true;try{setFormOwner(this,owner)}finally{this.reflectingFormOwner=false}}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}[VALIDITY_ANCHOR](){return this.renderRoot?.querySelector("input:not([type='hidden']), textarea, select, button, [tabindex]:not([tabindex='-1'])")??null}[SET_ANCHORED_VALIDITY](flags,message=""){this.validityController.setValidity(flags,message);this.syncValidityStates()}setCustomValidity(message){this.validityController.setCustomValidity(message??"");this.syncValidityStates()}resetValidity(){this.validityController.setCustomValidity("");this.updateValidity();this.syncValidityStates()}syncValidityStates(){syncValidityStates(this.internals,{required:this.required,hasInteracted:this._hasInteracted,barred:this.isBarredFromValidation()})}isBarredFromValidation(){return isBarredFromValidation(this,this.internals)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"";if(this._name){this.setAttribute("name",this._name)}else{this.removeAttribute("name")}this.requestUpdate("name",old)}commitFormValue(value){const submitted=adapter.toFormValue(value);if(adapter.toFormState)this.internals.setFormValue(submitted,adapter.toFormState(value));else this.internals.setFormValue(submitted)}get value(){return this._value}set value(next){const old=this._value;this._value=next??adapter.empty;if(!this.settingDefaultValue)this._valueDirty=true;this.commitFormValue(this._value);this.updateValidity();this.requestUpdate("value",old)}get defaultValue(){return this._defaultValue}set defaultValue(next){if(this.reflectingDefaultValue)return;const old=this._defaultValue;this._defaultValue=next??adapter.empty;this.reflectingDefaultValue=true;try{const attribute=next==null?null:adapter.toAttribute(this._defaultValue);if(attribute==null)this.removeAttribute("value");else this.setAttribute("value",attribute)}finally{this.reflectingDefaultValue=false}if(!this._valueDirty)this.restoreLiveValueFromDefault();this.requestUpdate("defaultValue",old)}get customError(){return this.validityController.customValidityMessage||null}set customError(next){if(this.reflectingCustomError)return;const old=this.customError;const message=next??"";this.reflectingCustomError=true;try{if(next==null)this.removeAttribute("custom-error");else this.setAttribute("custom-error",message)}finally{this.reflectingCustomError=false}this.setCustomValidity(message);this.requestUpdate("customError",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=Boolean(next);this.toggleAttribute("disabled",this._disabled);this.updateValidity();this.syncValidityStates();this.requestUpdate("disabled",old)}toggleAttribute(qualifiedName,force){if(qualifiedName!=="disabled")return super.toggleAttribute(qualifiedName,force);this._reflectingDisabledAttribute=true;try{return super.toggleAttribute(qualifiedName,force)}finally{queueMicrotask(()=>{this._reflectingDisabledAttribute=false})}}setAttribute(qualifiedName,value){if(qualifiedName!=="disabled"){super.setAttribute(qualifiedName,value);return}this._reflectingDisabledAttribute=true;try{super.setAttribute(qualifiedName,value)}finally{queueMicrotask(()=>{this._reflectingDisabledAttribute=false})}}removeAttribute(qualifiedName){if(qualifiedName!=="disabled"){super.removeAttribute(qualifiedName);return}this._reflectingDisabledAttribute=true;try{super.removeAttribute(qualifiedName)}finally{queueMicrotask(()=>{this._reflectingDisabledAttribute=false})}}get required(){return this._required}set required(next){const old=this._required;this._required=next;this.toggleAttribute("required",next);this.updateValidity();this.syncValidityStates();this.requestUpdate("required",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}setFormValue(next){this.value=next}updateValidity(){if(this.isBarredFromValidation()){this[SET_ANCHORED_VALIDITY]({});return}if(this.required&&adapter.isEmpty(this._value)){const overrides=this.strings;const message=resolveLyraString(this,"fieldRequired",overrides,void 0,void 0,FORM_ASSOCIATED_DEFAULT_STRINGS);this[SET_ANCHORED_VALIDITY]({valueMissing:true},message)}else{this[SET_ANCHORED_VALIDITY]({})}}syncConstraintsToNative(){const host=this;if(!host.hasUpdated)return;host.performUpdate()}checkValidity(){this.syncConstraintsToNative();this.updateValidity();return this.internals.checkValidity()}reportValidity(){this.syncConstraintsToNative();this.updateValidity();this._hasInteracted=true;this.syncValidityStates();return this.internals.reportValidity()}formResetCallback(){this._valueDirty=false;this.restoreLiveValueFromDefault();this._hasInteracted=false;this.syncValidityStates()}restoreLiveValueFromDefault(){this.settingDefaultValue=true;try{this.value=this._defaultValue}finally{this.settingDefaultValue=false}this._valueDirty=false}formStateRestoreCallback(state,reason){void reason;this.value=adapter.fromFormState(state)}formDisabledCallback(fieldsetDisabled){if(this._reflectingDisabledAttribute)return;const before=this.effectiveDisabled;this._fieldsetDisabled=fieldsetDisabled;if(this.effectiveDisabled===before)return;this.updateValidity();this.syncValidityStates();this.requestUpdate()}updated(changed){super.updated(changed);if(!changed.has("readonly")&&!changed.has("disabled"))return;this.updateValidity();this.syncValidityStates()}connectedCallback(){super.connectedCallback();this.updateValidity();this.syncValidityStates()}}return FormAssociatedElement}export{FormAssociated,attachInternalsSafely,createFallbackInternals,createStringArrayFormDataState,getFormOwner,installCustomErrorProperty,isBarredFromValidation,isEmptyFormValue,readStringArrayFormDataState,setFormOwner,stringFormValueAdapter};
|
|
@@ -47,6 +47,19 @@ export declare function invalidateLyraLocaleCache(host: Element): void;
|
|
|
47
47
|
export declare function resolveLyraLocale(host: Element): string;
|
|
48
48
|
/** Resolve the direction inherited by a component host. */
|
|
49
49
|
export declare function resolveLyraDirection(host: Element): 'ltr' | 'rtl';
|
|
50
|
+
/**
|
|
51
|
+
* Reads a host's already-memoized locale/direction without resolving anything -- in particular,
|
|
52
|
+
* without `resolveLyraDirection()`'s `getComputedStyle()` call. `undefined` when the host was
|
|
53
|
+
* never opted into caching, or opted in but never actually read `effectiveLocale`/
|
|
54
|
+
* `effectiveDirection` (so its own render never populated the memo). Lets a caller establish a
|
|
55
|
+
* "what's currently rendered" baseline for free, piggybacking on whatever the host's own last
|
|
56
|
+
* render already computed, instead of forcing a fresh (potentially expensive or, for
|
|
57
|
+
* `getComputedStyle()` specifically, disruptive -- see `observeInheritedContext()`) resolution
|
|
58
|
+
* purely to seed a comparison.
|
|
59
|
+
*/
|
|
60
|
+
export declare function peekLyraLocale(host: Element): string | undefined;
|
|
61
|
+
/** @see peekLyraLocale */
|
|
62
|
+
export declare function peekLyraDirection(host: Element): 'ltr' | 'rtl' | undefined;
|
|
50
63
|
/**
|
|
51
64
|
* Resolve a message for a component. An explicit per-component override wins,
|
|
52
65
|
* followed by a non-empty component property fallback, registered locale
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getPluralRules}from"./intl-cache.js";const locales=new Map;const localeMeta=new Map;const exactOnlyLocales=new Set;const listeners=new Set;const registryListeners=new Set;let activeLocale="";function normalizeLocale(locale){return locale.trim().replace(/_/g,"-").toLowerCase()}function regionalFallbacks(subtags){const language=subtags[0];if(!language)return[];const requested=new Set(subtags);const score=key=>key.split("-").filter(subtag=>requested.has(subtag)).length;return[...locales.keys()].filter(key=>!exactOnlyLocales.has(key)&&key.split("-")[0]===language&&!isPrefixOf(key,subtags)).sort((a,b)=>score(b)-score(a)||(a<b?-1:a>b?1:0))}function isPrefixOf(key,subtags){const parts=key.split("-");return parts.length<=subtags.length&&parts.every((part,index)=>part===subtags[index])}function localeCandidates(locale){const normalized=normalizeLocale(locale);const subtags=normalized.split("-").filter(Boolean);const candidates=[];for(let length=subtags.length;length>0;length--){candidates.push(subtags.slice(0,length).join("-"))}candidates.push(...regionalFallbacks(subtags));if(!candidates.includes("en"))candidates.push("en");return candidates}function notify(){for(const listener of[...listeners])listener()}function getRegisteredLyraLocales(){const keys=new Set(["en",...locales.keys()]);return[...keys].sort()}function subscribeLyraLocaleRegistry(listener){registryListeners.add(listener);return()=>registryListeners.delete(listener)}function registerLocale(locale,strings,meta,exactOnly){const key=normalizeLocale(locale);if(!key)throw new TypeError("A locale is required.");if(exactOnly)exactOnlyLocales.add(key);locales.set(key,{...locales.get(key)??{},...strings});if(meta)localeMeta.set(key,{...localeMeta.get(key)??{},...meta});pluralLocaleCache.clear();notify();for(const listener of[...registryListeners])listener()}function registerLyraLocale(locale,strings,meta){registerLocale(locale,strings,meta,false)}function registerLyraExactLocale(locale,strings,meta){registerLocale(locale,strings,meta,true)}function getLyraLocaleDirection(locale){const normalized=normalizeLocale(locale);if(!normalized)return"ltr";for(const candidate of localeCandidates(normalized)){const declared=localeMeta.get(candidate)?.dir;if(declared)return declared}try{const resolved=new Intl.Locale(normalized);const direction=resolved.textInfo?.direction??resolved.getTextInfo?.().direction;return direction==="rtl"?"rtl":"ltr"}catch{return"ltr"}}function setLyraLocale(locale){const next=locale.trim();if(activeLocale===next)return;activeLocale=next;notify()}function getLyraLocale(){return activeLocale}function subscribeLyraLocale(listener){listeners.add(listener);return()=>listeners.delete(listener)}function inheritedLocale(host){const explicit=host.getAttribute("locale")||host.getAttribute("lang");if(explicit)return explicit;const composedParent=element=>{if(element.parentElement)return element.parentElement;const root=element.getRootNode();const candidate=root.host;return root.nodeType===11&&candidate!==null&&typeof candidate==="object"&&typeof candidate.getAttribute==="function"?candidate:null};let parent=composedParent(host);while(parent){const locale=parent.getAttribute("locale")||parent.getAttribute("lang");if(locale)return locale;parent=composedParent(parent)}const documentLocale=host.ownerDocument?.documentElement?.getAttribute("lang");if(documentLocale)return documentLocale;return activeLocale||"en"}const cacheableLocaleHosts=new WeakSet;const resolvedLocaleCache=new WeakMap;const resolvedDirectionCache=new WeakMap;function enableLyraLocaleCache(host){cacheableLocaleHosts.add(host)}function invalidateLyraLocaleCache(host){resolvedLocaleCache.delete(host);resolvedDirectionCache.delete(host)}function resolveLyraLocale(host){if(!cacheableLocaleHosts.has(host))return inheritedLocale(host);let locale=resolvedLocaleCache.get(host);if(locale===void 0){locale=inheritedLocale(host);resolvedLocaleCache.set(host,locale)}return locale}function inheritedDirection(host){const explicit=host.getAttribute("dir");if(explicit==="rtl"||explicit==="ltr")return explicit;const view=host.ownerDocument?.defaultView;if(view)return view.getComputedStyle(host).direction==="rtl"?"rtl":"ltr";return"ltr"}function resolveLyraDirection(host){if(!cacheableLocaleHosts.has(host))return inheritedDirection(host);let direction=resolvedDirectionCache.get(host);if(direction===void 0){direction=inheritedDirection(host);resolvedDirectionCache.set(host,direction)}return direction}const PLURAL_CATEGORY_FALLBACKS={zero:["zero","other"],one:["one","other"],two:["two","few","many","other"],few:["few","many","other"],many:["many","few","other"],other:["other"]};function isPluralMessage(message){return typeof message==="object"}function pluralSelector(values){const raw=values["pluralCount"]??values["count"];return typeof raw==="number"&&Number.isFinite(raw)?raw:void 0}const pluralLocaleCache=new Map;const MAX_PLURAL_LOCALE_ENTRIES=64;function pluralLocale(locale){const cached=pluralLocaleCache.get(locale);if(cached!==void 0||pluralLocaleCache.has(locale))return cached;let resolved;for(const candidate of localeCandidates(locale)){try{getPluralRules(candidate);resolved=candidate;break}catch{}}if(pluralLocaleCache.size>=MAX_PLURAL_LOCALE_ENTRIES)pluralLocaleCache.clear();pluralLocaleCache.set(locale,resolved);return resolved}function selectPluralMessage(message,locale,count){if(count===void 0)return message.other;const tag=pluralLocale(locale);if(tag===void 0)return message.other;const category=getPluralRules(tag).select(count);for(const candidate of PLURAL_CATEGORY_FALLBACKS[category]??PLURAL_CATEGORY_FALLBACKS.other){const text=message[candidate];if(text!==void 0)return text}return message.other}function resolveLyraString(host,key,overrides,fallback,values,defaults){const own=overrides?.[key];let message=own??fallback;let locale;if(message===void 0){locale=resolveLyraLocale(host);for(const candidate of localeCandidates(locale)){const registered=locales.get(candidate)?.[key];if(registered!==void 0){message=registered;break}}}message??=defaults?.[key]??key;let text;if(isPluralMessage(message)){locale??=resolveLyraLocale(host);text=selectPluralMessage(message,locale,values?pluralSelector(values):void 0)}else{text=message}if(!values)return text;return text.replace(/\{(\w+)\}/g,(_match,name)=>String(values[name]??`{${name}}`))}function resolveLocalizedParts(template,interpolate){let marker="\uE000";while(template.includes(marker))marker+="\uE001";return interpolate(marker).split(marker)}export{enableLyraLocaleCache,getLyraLocale,getLyraLocaleDirection,getRegisteredLyraLocales,invalidateLyraLocaleCache,registerLyraExactLocale,registerLyraLocale,resolveLocalizedParts,resolveLyraDirection,resolveLyraLocale,resolveLyraString,setLyraLocale,subscribeLyraLocale,subscribeLyraLocaleRegistry};
|
|
1
|
+
import{getPluralRules}from"./intl-cache.js";const locales=new Map;const localeMeta=new Map;const exactOnlyLocales=new Set;const listeners=new Set;const registryListeners=new Set;let activeLocale="";function normalizeLocale(locale){return locale.trim().replace(/_/g,"-").toLowerCase()}function regionalFallbacks(subtags){const language=subtags[0];if(!language)return[];const requested=new Set(subtags);const score=key=>key.split("-").filter(subtag=>requested.has(subtag)).length;return[...locales.keys()].filter(key=>!exactOnlyLocales.has(key)&&key.split("-")[0]===language&&!isPrefixOf(key,subtags)).sort((a,b)=>score(b)-score(a)||(a<b?-1:a>b?1:0))}function isPrefixOf(key,subtags){const parts=key.split("-");return parts.length<=subtags.length&&parts.every((part,index)=>part===subtags[index])}function localeCandidates(locale){const normalized=normalizeLocale(locale);const subtags=normalized.split("-").filter(Boolean);const candidates=[];for(let length=subtags.length;length>0;length--){candidates.push(subtags.slice(0,length).join("-"))}candidates.push(...regionalFallbacks(subtags));if(!candidates.includes("en"))candidates.push("en");return candidates}function notify(){for(const listener of[...listeners])listener()}function getRegisteredLyraLocales(){const keys=new Set(["en",...locales.keys()]);return[...keys].sort()}function subscribeLyraLocaleRegistry(listener){registryListeners.add(listener);return()=>registryListeners.delete(listener)}function registerLocale(locale,strings,meta,exactOnly){const key=normalizeLocale(locale);if(!key)throw new TypeError("A locale is required.");if(exactOnly)exactOnlyLocales.add(key);locales.set(key,{...locales.get(key)??{},...strings});if(meta)localeMeta.set(key,{...localeMeta.get(key)??{},...meta});pluralLocaleCache.clear();notify();for(const listener of[...registryListeners])listener()}function registerLyraLocale(locale,strings,meta){registerLocale(locale,strings,meta,false)}function registerLyraExactLocale(locale,strings,meta){registerLocale(locale,strings,meta,true)}function getLyraLocaleDirection(locale){const normalized=normalizeLocale(locale);if(!normalized)return"ltr";for(const candidate of localeCandidates(normalized)){const declared=localeMeta.get(candidate)?.dir;if(declared)return declared}try{const resolved=new Intl.Locale(normalized);const direction=resolved.textInfo?.direction??resolved.getTextInfo?.().direction;return direction==="rtl"?"rtl":"ltr"}catch{return"ltr"}}function setLyraLocale(locale){const next=locale.trim();if(activeLocale===next)return;activeLocale=next;notify()}function getLyraLocale(){return activeLocale}function subscribeLyraLocale(listener){listeners.add(listener);return()=>listeners.delete(listener)}function inheritedLocale(host){const explicit=host.getAttribute("locale")||host.getAttribute("lang");if(explicit)return explicit;const composedParent=element=>{if(element.parentElement)return element.parentElement;const root=element.getRootNode();const candidate=root.host;return root.nodeType===11&&candidate!==null&&typeof candidate==="object"&&typeof candidate.getAttribute==="function"?candidate:null};let parent=composedParent(host);while(parent){const locale=parent.getAttribute("locale")||parent.getAttribute("lang");if(locale)return locale;parent=composedParent(parent)}const documentLocale=host.ownerDocument?.documentElement?.getAttribute("lang");if(documentLocale)return documentLocale;return activeLocale||"en"}const cacheableLocaleHosts=new WeakSet;const resolvedLocaleCache=new WeakMap;const resolvedDirectionCache=new WeakMap;function enableLyraLocaleCache(host){cacheableLocaleHosts.add(host)}function invalidateLyraLocaleCache(host){resolvedLocaleCache.delete(host);resolvedDirectionCache.delete(host)}function resolveLyraLocale(host){if(!cacheableLocaleHosts.has(host))return inheritedLocale(host);let locale=resolvedLocaleCache.get(host);if(locale===void 0){locale=inheritedLocale(host);resolvedLocaleCache.set(host,locale)}return locale}function inheritedDirection(host){const explicit=host.getAttribute("dir");if(explicit==="rtl"||explicit==="ltr")return explicit;const view=host.ownerDocument?.defaultView;if(view)return view.getComputedStyle(host).direction==="rtl"?"rtl":"ltr";return"ltr"}function resolveLyraDirection(host){if(!cacheableLocaleHosts.has(host))return inheritedDirection(host);let direction=resolvedDirectionCache.get(host);if(direction===void 0){direction=inheritedDirection(host);resolvedDirectionCache.set(host,direction)}return direction}function peekLyraLocale(host){return resolvedLocaleCache.get(host)}function peekLyraDirection(host){return resolvedDirectionCache.get(host)}const PLURAL_CATEGORY_FALLBACKS={zero:["zero","other"],one:["one","other"],two:["two","few","many","other"],few:["few","many","other"],many:["many","few","other"],other:["other"]};function isPluralMessage(message){return typeof message==="object"}function pluralSelector(values){const raw=values["pluralCount"]??values["count"];return typeof raw==="number"&&Number.isFinite(raw)?raw:void 0}const pluralLocaleCache=new Map;const MAX_PLURAL_LOCALE_ENTRIES=64;function pluralLocale(locale){const cached=pluralLocaleCache.get(locale);if(cached!==void 0||pluralLocaleCache.has(locale))return cached;let resolved;for(const candidate of localeCandidates(locale)){try{getPluralRules(candidate);resolved=candidate;break}catch{}}if(pluralLocaleCache.size>=MAX_PLURAL_LOCALE_ENTRIES)pluralLocaleCache.clear();pluralLocaleCache.set(locale,resolved);return resolved}function selectPluralMessage(message,locale,count){if(count===void 0)return message.other;const tag=pluralLocale(locale);if(tag===void 0)return message.other;const category=getPluralRules(tag).select(count);for(const candidate of PLURAL_CATEGORY_FALLBACKS[category]??PLURAL_CATEGORY_FALLBACKS.other){const text=message[candidate];if(text!==void 0)return text}return message.other}function resolveLyraString(host,key,overrides,fallback,values,defaults){const own=overrides?.[key];let message=own??fallback;let locale;if(message===void 0){locale=resolveLyraLocale(host);for(const candidate of localeCandidates(locale)){const registered=locales.get(candidate)?.[key];if(registered!==void 0){message=registered;break}}}message??=defaults?.[key]??key;let text;if(isPluralMessage(message)){locale??=resolveLyraLocale(host);text=selectPluralMessage(message,locale,values?pluralSelector(values):void 0)}else{text=message}if(!values)return text;return text.replace(/\{(\w+)\}/g,(_match,name)=>String(values[name]??`{${name}}`))}function resolveLocalizedParts(template,interpolate){let marker="\uE000";while(template.includes(marker))marker+="\uE001";return interpolate(marker).split(marker)}export{enableLyraLocaleCache,getLyraLocale,getLyraLocaleDirection,getRegisteredLyraLocales,invalidateLyraLocaleCache,peekLyraDirection,peekLyraLocale,registerLyraExactLocale,registerLyraLocale,resolveLocalizedParts,resolveLyraDirection,resolveLyraLocale,resolveLyraString,setLyraLocale,subscribeLyraLocale,subscribeLyraLocaleRegistry};
|
|
@@ -68,6 +68,21 @@ export declare class LyraElement<Events = LyraEventMap> extends LitElement {
|
|
|
68
68
|
*/
|
|
69
69
|
requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: PropertyDeclaration): void;
|
|
70
70
|
attributeChangedCallback(name: string, oldValue: string | null, value: string | null): void;
|
|
71
|
+
/**
|
|
72
|
+
* `class`/`style` sit in {@link INHERITED_CONTEXT_ATTRIBUTES} so a CSS-only ancestor direction
|
|
73
|
+
* change (`.rtl-context { direction: rtl }`, an inline `style="direction: rtl"`) is still
|
|
74
|
+
* picked up with no `dir` attribute anywhere — see the "reads computed direction live after
|
|
75
|
+
* ancestor style and class changes" test. But `class`/`style` also cover every OTHER reason an
|
|
76
|
+
* ancestor's inline style or class list might change, most of which have nothing to do with
|
|
77
|
+
* direction or locale (an overlay's own `--lr-overlay-stack-index` custom property, a consumer's
|
|
78
|
+
* unrelated theming class, …). A MutationObserver callback is its own microtask, scheduled
|
|
79
|
+
* independently of Lit's update batching, so an unconditional `requestUpdate()` here could land
|
|
80
|
+
* inside another in-flight update's `updated()`/`hostUpdated()` window purely because of a
|
|
81
|
+
* direction-irrelevant style write on some unrelated ancestor — Lit's dev-mode "scheduled an
|
|
82
|
+
* update after an update completed" warning, for a re-render that was never actually warranted
|
|
83
|
+
* (fr_asxOgk4UhNB07xevCWwFVQ). Comparing the freshly resolved direction/locale against the last
|
|
84
|
+
* observed pair keeps the feature intact while dropping every spurious trigger.
|
|
85
|
+
*/
|
|
71
86
|
private observeInheritedContext;
|
|
72
87
|
/**
|
|
73
88
|
* Runs `seed` before the first render — except while hydrating a server-rendered shadow root,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};import{LitElement}from"lit";import{property}from"lit/decorators.js";import{captureFormInternals,ExternalLabelController}from"./form-control-labels.js";import{tokens}from"./tokens.styles.js";import{palette}from"./tokens/palette.styles.js";import{resolveIntlLocale}from"./intl-cache.js";import{enableLyraLocaleCache,invalidateLyraLocaleCache,resolveLyraDirection,resolveLyraString,resolveLyraLocale,subscribeLyraLocale}from"./localization-runtime.js";const REACTIVE_HOST_ATTRIBUTES=["aria-label","aria-describedby","lang","dir"];const DIRECTION_HOST_ATTRIBUTES=["class","style"];const INHERITED_CONTEXT_ATTRIBUTES=["locale","lang","dir","class","style"];function composedParentElement(element){if(element.parentElement)return element.parentElement;const root=element.getRootNode();const candidate=root.host;return root.nodeType===11&&candidate!==null&&typeof candidate==="object"&&typeof candidate.getAttribute==="function"?candidate:null}class LyraElement extends LitElement{static{this.styles=[palette,tokens]}static{this.defaultStrings=Object.freeze({})}static get observedAttributes(){return[...new Set([...super.observedAttributes,...REACTIVE_HOST_ATTRIBUTES,...DIRECTION_HOST_ATTRIBUTES])]}constructor(){super();this.locale="";this.strings={};if(this.constructor.formAssociated){this.addController(new ExternalLabelController(this))}}attachInternals(){const internals=super.attachInternals();captureFormInternals(this,internals);return internals}connectedCallback(){this.hydratingServerShadow??=!this.hasUpdated&&this.shadowRoot!==null;super.connectedCallback();enableLyraLocaleCache(this);invalidateLyraLocaleCache(this);this.observeInheritedContext();this.stopLocaleSubscription=subscribeLyraLocale(()=>this.requestUpdate());const deferred=this.deferredAfterUpdate;if(deferred){this.deferredAfterUpdate=void 0;for(const[key,callback]of deferred)this.scheduleAfterUpdate(callback,key)}}disconnectedCallback(){this.pendingLoadController?.abort();this.pendingLoadController=void 0;this.stopLocaleSubscription?.();this.stopLocaleSubscription=void 0;this.inheritedContextObserver?.disconnect();this.inheritedContextObserver=void 0;invalidateLyraLocaleCache(this);super.disconnectedCallback()}requestUpdate(name,oldValue,options){invalidateLyraLocaleCache(this);super.requestUpdate(name,oldValue,options)}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value);if(oldValue!==value&&REACTIVE_HOST_ATTRIBUTES.includes(name)){this.requestUpdate()}else if(oldValue!==value&&DIRECTION_HOST_ATTRIBUTES.includes(name)){invalidateLyraLocaleCache(this)}}observeInheritedContext(){this.inheritedContextObserver?.disconnect();const Observer=this.ownerDocument?.defaultView?.MutationObserver;if(!Observer)return;const observer=new Observer(()
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};import{LitElement}from"lit";import{property}from"lit/decorators.js";import{captureFormInternals,ExternalLabelController}from"./form-control-labels.js";import{tokens}from"./tokens.styles.js";import{palette}from"./tokens/palette.styles.js";import{resolveIntlLocale}from"./intl-cache.js";import{enableLyraLocaleCache,invalidateLyraLocaleCache,peekLyraDirection,peekLyraLocale,resolveLyraDirection,resolveLyraString,resolveLyraLocale,subscribeLyraLocale}from"./localization-runtime.js";const REACTIVE_HOST_ATTRIBUTES=["aria-label","aria-describedby","lang","dir"];const DIRECTION_HOST_ATTRIBUTES=["class","style"];const INHERITED_CONTEXT_ATTRIBUTES=["locale","lang","dir","class","style"];function composedParentElement(element){if(element.parentElement)return element.parentElement;const root=element.getRootNode();const candidate=root.host;return root.nodeType===11&&candidate!==null&&typeof candidate==="object"&&typeof candidate.getAttribute==="function"?candidate:null}const STYLE_DIRECTION_PATTERN=/(?:^|[;\s])direction\s*:\s*([^;]+)/i;function styleDirectionDeclaration(styleText){return STYLE_DIRECTION_PATTERN.exec(styleText)?.[1]?.trim()}class LyraElement extends LitElement{static{this.styles=[palette,tokens]}static{this.defaultStrings=Object.freeze({})}static get observedAttributes(){return[...new Set([...super.observedAttributes,...REACTIVE_HOST_ATTRIBUTES,...DIRECTION_HOST_ATTRIBUTES])]}constructor(){super();this.locale="";this.strings={};if(this.constructor.formAssociated){this.addController(new ExternalLabelController(this))}}attachInternals(){const internals=super.attachInternals();captureFormInternals(this,internals);return internals}connectedCallback(){this.hydratingServerShadow??=!this.hasUpdated&&this.shadowRoot!==null;super.connectedCallback();enableLyraLocaleCache(this);invalidateLyraLocaleCache(this);this.observeInheritedContext();this.stopLocaleSubscription=subscribeLyraLocale(()=>this.requestUpdate());const deferred=this.deferredAfterUpdate;if(deferred){this.deferredAfterUpdate=void 0;for(const[key,callback]of deferred)this.scheduleAfterUpdate(callback,key)}}disconnectedCallback(){this.pendingLoadController?.abort();this.pendingLoadController=void 0;this.stopLocaleSubscription?.();this.stopLocaleSubscription=void 0;this.inheritedContextObserver?.disconnect();this.inheritedContextObserver=void 0;invalidateLyraLocaleCache(this);super.disconnectedCallback()}requestUpdate(name,oldValue,options){invalidateLyraLocaleCache(this);super.requestUpdate(name,oldValue,options)}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value);if(oldValue!==value&&REACTIVE_HOST_ATTRIBUTES.includes(name)){this.requestUpdate()}else if(oldValue!==value&&DIRECTION_HOST_ATTRIBUTES.includes(name)){invalidateLyraLocaleCache(this)}}observeInheritedContext(){this.inheritedContextObserver?.disconnect();const Observer=this.ownerDocument?.defaultView?.MutationObserver;if(!Observer)return;let lastLocale;let lastDirection;let checkQueued=false;let recheckDirection=false;const check=()=>{checkQueued=false;const resolveDirection=recheckDirection;recheckDirection=false;lastLocale??=peekLyraLocale(this);if(resolveDirection)lastDirection??=peekLyraDirection(this);const priorLocale=lastLocale;const priorDirection=lastDirection;invalidateLyraLocaleCache(this);const locale=resolveLyraLocale(this);lastLocale=locale;const localeChanged=priorLocale!==void 0&&locale!==priorLocale;let directionChanged=false;if(resolveDirection){const direction=resolveLyraDirection(this);directionChanged=priorDirection!==void 0&&direction!==priorDirection;lastDirection=direction}if(localeChanged||directionChanged)this.requestUpdate()};const observer=new Observer(records=>{for(const record of records){if(record.attributeName==="dir"||record.attributeName==="class"){recheckDirection=true;break}if(record.attributeName==="style"){const target=record.target;const before=record.oldValue??"";const after=target.getAttribute("style")??"";if(styleDirectionDeclaration(before)!==styleDirectionDeclaration(after)){recheckDirection=true;break}}}if(checkQueued)return;checkQueued=true;queueMicrotask(check)});let ancestor=composedParentElement(this);while(ancestor){observer.observe(ancestor,{attributes:true,attributeOldValue:true,attributeFilter:[...INHERITED_CONTEXT_ATTRIBUTES]});ancestor=composedParentElement(ancestor)}this.inheritedContextObserver=observer}seedFirstRenderState(seed){if(this.hasUpdated)return;if(!this.hydratingServerShadow){seed();return}void this.updateComplete.then(()=>{this.hydratingServerShadow=false;seed()},()=>{this.hydratingServerShadow=false})}beginAbortableLoad(){this.pendingLoadController?.abort();this.pendingLoadController=void 0;const AbortControllerCtor=this.ownerDocument.defaultView?.AbortController;if(!AbortControllerCtor)return void 0;this.pendingLoadController=new AbortControllerCtor;return this.pendingLoadController.signal}scheduleAfterUpdate(callback,key="load"){const pending=this.afterUpdateCallbacks??=new Map;if(pending.has(key))return;pending.set(key,callback);if(pending.size>1)return;queueMicrotask(()=>{const due=this.afterUpdateCallbacks;this.afterUpdateCallbacks=void 0;if(!due)return;if(this.isConnected){for(const due_callback of due.values())due_callback();return}const held=this.deferredAfterUpdate??=new Map;for(const[heldKey,heldCallback]of due)if(!held.has(heldKey))held.set(heldKey,heldCallback)})}localize(key,fallback,values){return resolveLyraString(this,key,this.strings,fallback,values,this.constructor.defaultStrings)}get effectiveMessageLocale(){return this.locale||resolveLyraLocale(this)}get effectiveLocale(){return resolveIntlLocale(this.effectiveMessageLocale)}get effectiveIntlLocale(){return this.effectiveLocale}get effectiveDirection(){return resolveLyraDirection(this)}addEventListener(type,listener,options){super.addEventListener(type,listener,options)}removeEventListener(type,listener,options){super.removeEventListener(type,listener,options)}emit(name,...args){const[detail,options]=args;const ownerDocument=this.ownerDocument;let CustomEventCtor=ownerDocument?.defaultView?.CustomEvent;if(!CustomEventCtor&&ownerDocument){try{const candidate=ownerDocument.createEvent("CustomEvent").constructor;if(typeof candidate==="function"){CustomEventCtor=candidate}}catch{}}CustomEventCtor??=globalThis.CustomEvent;const event=new CustomEventCtor(name,{detail,bubbles:true,composed:true,cancelable:options?.cancelable??false});this.dispatchEvent(event);return event}}__decorate([property({reflect:true})],LyraElement.prototype,"locale",void 0);__decorate([property({attribute:false})],LyraElement.prototype,"strings",void 0);export{LyraElement};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const LYRA_PACKAGE_NAME="@aceshooting/lyra-ui";const LYRA_PACKAGE_VERSION="8.1
|
|
1
|
+
const LYRA_PACKAGE_NAME="@aceshooting/lyra-ui";const LYRA_PACKAGE_VERSION="8.2.1";export{LYRA_PACKAGE_NAME,LYRA_PACKAGE_VERSION};
|
|
@@ -45,5 +45,5 @@ export declare function installHappyDomFormAssociatedShims(): void;
|
|
|
45
45
|
/** Test-only: returns a fresh stub `ElementInternals`-shaped object, independent of whether
|
|
46
46
|
* `attachInternals` already exists natively -- exists purely so this module's own test can
|
|
47
47
|
* verify the stub's call-shape coverage without needing to run under happy-dom itself. */
|
|
48
|
-
export declare function installStubInternalsForTest(
|
|
48
|
+
export declare function installStubInternalsForTest(host: Element): StubElementInternals;
|
|
49
49
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function createStubInternals(){return{form
|
|
1
|
+
function createStubInternals(host){return{get form(){return host.closest("form")},labels:document.createDocumentFragment().querySelectorAll("label"),states:new Set,validity:{valid:true},validationMessage:"",willValidate:true,setFormValue(){},checkValidity(){return true},reportValidity(){return true},setValidity(){}}}function installHappyDomFormAssociatedShims(){if(typeof HTMLElement==="undefined")return;if(typeof HTMLElement.prototype.attachInternals==="function")return;HTMLElement.prototype.attachInternals=function attachInternals(){return createStubInternals(this)}}function installStubInternalsForTest(host){return createStubInternals(host)}export{installHappyDomFormAssociatedShims,installStubInternalsForTest};
|
|
@@ -40,6 +40,8 @@ goes back to `valueMissing`. It survives every child toggle, slot change and for
|
|
|
40
40
|
Session restore uses a `FormData` state containing the repeated selected strings; it is independent
|
|
41
41
|
of the control's current `name`, preserves duplicate-value cardinality, waits for early-arriving
|
|
42
42
|
option children, and falls back to an empty selection for malformed state. Restoration is silent.
|
|
43
|
+
`click()` forwards focus to the first enabled checkbox, so the host behaves like a single control
|
|
44
|
+
rather than a no-op under a `<label>`-driven or programmatic click.
|
|
43
45
|
**CSS parts:** `form-control`, `form-control-label`, `options` / `form-control-input`, `hint`,
|
|
44
46
|
`error`.
|
|
45
47
|
**The required marker.** `required` with a non-empty group `label` paints the library's shared
|
|
@@ -33,7 +33,9 @@ restores the control's own computed validity rather than forcing it valid — a
|
|
|
33
33
|
field edit) and `form.reset()`, exactly like a native control, where only another
|
|
34
34
|
`setCustomValidity('')` clears it. The message is caller-supplied and is used verbatim, never
|
|
35
35
|
localized, and it is whole-control state: it does not land in `errors`, which is keyed by the
|
|
36
|
-
csspart of the field a message belongs to.
|
|
36
|
+
csspart of the field a message belongs to. `click()` forwards focus to the first rendered field
|
|
37
|
+
(start/end/hop-limit/direction/save-name, in that order), so the host behaves like a single
|
|
38
|
+
control rather than a no-op under a `<label>`-driven or programmatic click.
|
|
37
39
|
|
|
38
40
|
**Events:** `lr-input`, `lr-validity-change`, `lr-invalid` (no detail; one bubbling/composed alias
|
|
39
41
|
when the complete builder fails a native validity check),
|
|
@@ -71,4 +71,6 @@ options and its messages, scaled by `size` through the shared control ladder.
|
|
|
71
71
|
**Methods:** `setCustomValidity(message = '')` sets or clears a group-level consumer error. A
|
|
72
72
|
non-empty message raises `customError` and blocks submission; `setCustomValidity('')` and
|
|
73
73
|
`resetValidity()` restore the group's computed validity, including `valueMissing` when a required
|
|
74
|
-
group has no selected radio.
|
|
74
|
+
group has no selected radio. `focus()` moves focus to the selected (or first enabled) radio;
|
|
75
|
+
`click()` mirrors it by activating that same radio, so the group behaves like a single control
|
|
76
|
+
under both APIs rather than leaving `click()` a no-op.
|
|
@@ -46,6 +46,8 @@ express ("this item was already annotated by someone else"): a non-empty message
|
|
|
46
46
|
required keys, and any key with an unsupported `type`, still hold it invalid. It is independent of
|
|
47
47
|
the per-key `errors` map, which stays a read-out of this rubric's own field rules, so a message set
|
|
48
48
|
here is never attributed to one key. It survives every `value`/`keys` write and a form reset.
|
|
49
|
+
`click()` forwards to the active field (the same one a submit-and-next transition auto-focuses),
|
|
50
|
+
so the host behaves like a single control under both a `<label>`-driven and a programmatic click.
|
|
49
51
|
|
|
50
52
|
**CSS parts:** `base` (the outer `role="group"` wrapper), `field` (one key's wrapper), `label`, `description`,
|
|
51
53
|
`scale` (the rendered score/category/comment control's wrapper), `error` (a field-level validation
|
|
@@ -87,6 +87,9 @@ and makes the form invalid instead of being silently accepted.
|
|
|
87
87
|
re-runs the validity sync) and a `form.reset()`, matching a native control. The message is
|
|
88
88
|
whole-control state, so it is deliberately absent from `errors`, which is keyed by schema
|
|
89
89
|
property; it is caller-supplied content and is used verbatim, never localized.
|
|
90
|
+
- `click(): void` — forwards a host click to the first generated field's control, so the form
|
|
91
|
+
behaves like a single control under both a `<label>`-driven and a programmatic click; a no-op
|
|
92
|
+
while `disabled`.
|
|
90
93
|
|
|
91
94
|
**Events:** `lr-input` (`detail: { value: Record<string, unknown> }` — the full current value
|
|
92
95
|
object, every property with defaults resolved, not just the field that changed), `lr-validity-change`
|
package/llms/peers.md
CHANGED
|
@@ -53,7 +53,7 @@ changes the component library version without installing a supported SheetJS rel
|
|
|
53
53
|
| `postal-mime` | `^2.7.5` | `lr-email-viewer` |
|
|
54
54
|
| `qrcode` | `^1.5.4` | `lr-qr-code` |
|
|
55
55
|
| `react` | `>=19 <20` | type-only `@aceshooting/lyra-ui/custom-elements-jsx` entry (no runtime import) |
|
|
56
|
-
| `shiki` | `^4.4.
|
|
56
|
+
| `shiki` | `^4.4.2` | `lr-code-block`, `lr-code-block-core`, `lr-diff-view`, `lr-document-compare`, `lr-markdown`, `lr-markdown-core`, `lr-message-parts`, `lr-widget-renderer` |
|
|
57
57
|
| `svelte` | `>=5 <6` | type-only `@aceshooting/lyra-ui/svelte` entry (no runtime import) |
|
|
58
58
|
| `vue` | `>=3.5 <4` | type-only `@aceshooting/lyra-ui/vue` entry (no runtime import) |
|
|
59
59
|
| `xlsx` | `>=0.20.3 <0.21.0` | `lr-spreadsheet-viewer` |
|
package/llms-full.txt
CHANGED
|
@@ -5277,7 +5277,9 @@ options and its messages, scaled by `size` through the shared control ladder.
|
|
|
5277
5277
|
**Methods:** `setCustomValidity(message = '')` sets or clears a group-level consumer error. A
|
|
5278
5278
|
non-empty message raises `customError` and blocks submission; `setCustomValidity('')` and
|
|
5279
5279
|
`resetValidity()` restore the group's computed validity, including `valueMissing` when a required
|
|
5280
|
-
group has no selected radio.
|
|
5280
|
+
group has no selected radio. `focus()` moves focus to the selected (or first enabled) radio;
|
|
5281
|
+
`click()` mirrors it by activating that same radio, so the group behaves like a single control
|
|
5282
|
+
under both APIs rather than leaving `click()` a no-op.
|
|
5281
5283
|
|
|
5282
5284
|
## `lr-checkbox-group`
|
|
5283
5285
|
|
|
@@ -5306,6 +5308,8 @@ goes back to `valueMissing`. It survives every child toggle, slot change and for
|
|
|
5306
5308
|
Session restore uses a `FormData` state containing the repeated selected strings; it is independent
|
|
5307
5309
|
of the control's current `name`, preserves duplicate-value cardinality, waits for early-arriving
|
|
5308
5310
|
option children, and falls back to an empty selection for malformed state. Restoration is silent.
|
|
5311
|
+
`click()` forwards focus to the first enabled checkbox, so the host behaves like a single control
|
|
5312
|
+
rather than a no-op under a `<label>`-driven or programmatic click.
|
|
5309
5313
|
**CSS parts:** `form-control`, `form-control-label`, `options` / `form-control-input`, `hint`,
|
|
5310
5314
|
`error`.
|
|
5311
5315
|
**The required marker.** `required` with a non-empty group `label` paints the library's shared
|
|
@@ -5932,6 +5936,8 @@ express ("this item was already annotated by someone else"): a non-empty message
|
|
|
5932
5936
|
required keys, and any key with an unsupported `type`, still hold it invalid. It is independent of
|
|
5933
5937
|
the per-key `errors` map, which stays a read-out of this rubric's own field rules, so a message set
|
|
5934
5938
|
here is never attributed to one key. It survives every `value`/`keys` write and a form reset.
|
|
5939
|
+
`click()` forwards to the active field (the same one a submit-and-next transition auto-focuses),
|
|
5940
|
+
so the host behaves like a single control under both a `<label>`-driven and a programmatic click.
|
|
5935
5941
|
|
|
5936
5942
|
**CSS parts:** `base` (the outer `role="group"` wrapper), `field` (one key's wrapper), `label`, `description`,
|
|
5937
5943
|
`scale` (the rendered score/category/comment control's wrapper), `error` (a field-level validation
|
|
@@ -8532,7 +8538,9 @@ restores the control's own computed validity rather than forcing it valid — a
|
|
|
8532
8538
|
field edit) and `form.reset()`, exactly like a native control, where only another
|
|
8533
8539
|
`setCustomValidity('')` clears it. The message is caller-supplied and is used verbatim, never
|
|
8534
8540
|
localized, and it is whole-control state: it does not land in `errors`, which is keyed by the
|
|
8535
|
-
csspart of the field a message belongs to.
|
|
8541
|
+
csspart of the field a message belongs to. `click()` forwards focus to the first rendered field
|
|
8542
|
+
(start/end/hop-limit/direction/save-name, in that order), so the host behaves like a single
|
|
8543
|
+
control rather than a no-op under a `<label>`-driven or programmatic click.
|
|
8536
8544
|
|
|
8537
8545
|
**Events:** `lr-input`, `lr-validity-change`, `lr-invalid` (no detail; one bubbling/composed alias
|
|
8538
8546
|
when the complete builder fails a native validity check),
|
|
@@ -22936,6 +22944,9 @@ and makes the form invalid instead of being silently accepted.
|
|
|
22936
22944
|
re-runs the validity sync) and a `form.reset()`, matching a native control. The message is
|
|
22937
22945
|
whole-control state, so it is deliberately absent from `errors`, which is keyed by schema
|
|
22938
22946
|
property; it is caller-supplied content and is used verbatim, never localized.
|
|
22947
|
+
- `click(): void` — forwards a host click to the first generated field's control, so the form
|
|
22948
|
+
behaves like a single control under both a `<label>`-driven and a programmatic click; a no-op
|
|
22949
|
+
while `disabled`.
|
|
22939
22950
|
|
|
22940
22951
|
**Events:** `lr-input` (`detail: { value: Record<string, unknown> }` — the full current value
|
|
22941
22952
|
object, every property with defaults resolved, not just the field that changed), `lr-validity-change`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aceshooting/lyra-ui",
|
|
3
|
-
"version": "8.1
|
|
3
|
+
"version": "8.2.1",
|
|
4
4
|
"description": "Free, independent Lit web components: an open-source alternative to Shoelace and Web Awesome with accessible forms, dashboards, charts, and agent UI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
|
@@ -1379,7 +1379,7 @@
|
|
|
1379
1379
|
"postal-mime": "^2.7.5",
|
|
1380
1380
|
"qrcode": "^1.5.4",
|
|
1381
1381
|
"react": ">=19 <20",
|
|
1382
|
-
"shiki": "^4.4.
|
|
1382
|
+
"shiki": "^4.4.2",
|
|
1383
1383
|
"svelte": ">=5 <6",
|
|
1384
1384
|
"vue": ">=3.5 <4",
|
|
1385
1385
|
"xlsx": ">=0.20.3 <0.21.0"
|
|
@@ -1521,10 +1521,10 @@
|
|
|
1521
1521
|
"postal-mime": "^2.7.5",
|
|
1522
1522
|
"qrcode": "^1.5.4",
|
|
1523
1523
|
"react": "^19.2.8",
|
|
1524
|
-
"shiki": "^4.4.
|
|
1524
|
+
"shiki": "^4.4.2",
|
|
1525
1525
|
"svelte": "^5.56.8",
|
|
1526
1526
|
"typescript": "^7.0.2",
|
|
1527
|
-
"vue": "^3.5.
|
|
1527
|
+
"vue": "^3.5.41",
|
|
1528
1528
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
|
|
1529
1529
|
},
|
|
1530
1530
|
"customElements": "custom-elements.json",
|