@kubex/zinc 1.0.21 → 1.0.22
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.
|
@@ -26876,7 +26876,7 @@
|
|
|
26876
26876
|
"text": "string"
|
|
26877
26877
|
},
|
|
26878
26878
|
"privacy": "private",
|
|
26879
|
-
"default": "''"
|
|
26879
|
+
"default": "'en'"
|
|
26880
26880
|
},
|
|
26881
26881
|
{
|
|
26882
26882
|
"kind": "field",
|
|
@@ -27257,7 +27257,7 @@
|
|
|
27257
27257
|
"package": {
|
|
27258
27258
|
"name": "@kubex/zinc",
|
|
27259
27259
|
"description": "A collection of web components for building web applications based off of @shoelace-style/Shoelace",
|
|
27260
|
-
"version": "1.0.
|
|
27260
|
+
"version": "1.0.22",
|
|
27261
27261
|
"author": "",
|
|
27262
27262
|
"license": "MIT"
|
|
27263
27263
|
}
|
package/dist/web-types.json
CHANGED
package/dist/zn.min.js
CHANGED
|
@@ -5000,7 +5000,7 @@ button {
|
|
|
5000
5000
|
<zn-option value="${i.url}">${i.name}</zn-option>
|
|
5001
5001
|
`)}
|
|
5002
5002
|
</zn-select>
|
|
5003
|
-
`}};_o.styles=Z(U7),y([We()],_o.prototype,"_isPlaying",2),y([_()],_o.prototype,"value",2),y([_()],_o.prototype,"label",2),y([_()],_o.prototype,"placeholder",2),y([_({type:Object})],_o.prototype,"files",2);var zoe=_o;_o.define("zn-audio-select");var G7=te`.form-control-input{margin:var(--zn-spacing-2x-small) 3px 3px}.form-control .form-control__label{display:none}.form-control .form-control__help-text{display:none}.form-control--has-label .form-control__label{display:inline-block;color:var(--zn-input-label-color);font-weight:var(--zn-font-weight-semibold);margin-bottom:var(--zn-spacing-2x-small)}.form-control--has-label.form-control--medium .form-control__label{font-size:var(--zn-input-label-font-size-medium)}.form-control--has-label.form-control--large .form-control__label{font-size:var(--zn-input-label-font-size-large)}:host([required]) .form-control--has-label .form-control__label::after{content:var(--zn-input-required-content);margin-inline-start:var(--zn-input-required-content-offset);color:var(--zn-input-required-content-color)}.form-control--has-label.form-control--radio-group .form-control__label,.form-control--has-label.form-control--checkbox-group .form-control__label{margin-bottom:0}.form-control--has-label.form-control--has-label-tooltip .form-control__label{display:inline-flex;align-items:center;gap:var(--zn-spacing-2x-small)}.form-control--has-label.form-control--small .form-control__label{font-size:var(--zn-input-label-font-size-small)}.form-control--label-tooltip{color:var(--zn-color-neutral-700);font-size:var(--zn-font-size-small)}.form-control--label-tooltip zn-icon{--icon-color:var(--zn-color-neutral-700);--icon-size:var(--zn-font-size-small)}.form-control--has-label.form-control--has-context-note{display:flex;justify-content:space-between;flex-wrap:wrap}.form-control__label-context-note{color:var(--zn-input-help-text-color);font-size:var(--zn-font-size-small);margin-bottom:var(--zn-spacing-2x-small)}.form-control--has-label.form-control--has-context-note .form-control-input{width:100%}.form-control--has-help-text .form-control__help-text,.radio--has-description .radio__description,.checkbox--has-description .checkbox__description{display:block;color:var(--zn-input-help-text-color);margin-top:var(--zn-spacing-x-small)}.radio--has-description .radio__description,.checkbox--has-description .checkbox__description{margin-top:0.375rem}.radio--has-selected-content .radio__selected-content,.checkbox--has-selected-content .checkbox__selected-content{display:block;margin-top:var(--zn-spacing-small)}.form-control--has-help-text.form-control--small .form-control__help-text{font-size:var(--zn-input-help-text-font-size-small)}.form-control--has-help-text.form-control--medium .form-control__help-text,.radio--has-description .radio__description,.checkbox--has-description .checkbox__description{font-size:var(--zn-input-help-text-font-size-medium)}.form-control--has-help-text.form-control--large .form-control__help-text{font-size:var(--zn-input-help-text-font-size-large)}.form-control--has-help-text.form-control--radio-group .form-control__help-text,.form-control--has-help-text.form-control--checkbox-group .form-control__help-text{margin-top:var(--zn-spacing-medium)}.form-control--has-help-text .switch .form-control__help-text{margin-top:var(--zn-spacing-3x-small)}.form-control--checkbox-contained-wrapper{height:100%}:host{display:block}.translations{display:flex;flex-direction:column;gap:var(--zn-spacing-small)}.input-container{padding:var(--zn-spacing-small) 0}`;var On=class extends J{constructor(){super(...arguments);this.formControlController=new rt(this);this.hasSlotController=new Ue(this,"label");this.name="";this.value='{"en":""}';this.label="";this.disabled=!1;this.required=!1;this.languages={en:"English"};this.values={};this._activeLanguage="";this.handleLanguageAdd=i=>{let r=i.detail.element.getAttribute("data-path");r&&(this.values=et(Ce({},this.values),{[r]:""}),this._activeLanguage=r,this.updateValue())};this.handleNavbarClick=i=>{i.stopPropagation();let n=i.detail.item;if(n){let r=n.getAttribute("tab")||n.getAttribute("data-tab");r&&(this._activeLanguage=r,this.requestUpdate())}};this.handleValueUpdate=i=>{let n=i.target;if(this._activeLanguage){let r=n.value;r!==this.values[this._activeLanguage]&&(this.values=et(Ce({},this.values),{[this._activeLanguage]:r}),this.updateValue())}};this.handleKeyDown=i=>{if(i.key==="Enter"){if(i.target instanceof Tb)return;!(i.altKey||i.ctrlKey||i.metaKey||i.shiftKey)&&!i.defaultPrevented&&!i.isComposing&&this.formControlController.submit()}};this.handleSubmit=()=>{this.formControlController.submit()}}get validity(){return kn}get validationMessage(){return""}checkValidity(){return!0}getForm(){return this.formControlController.getForm()}reportValidity(){return!0}setCustomValidity(){}firstUpdated(){this.formControlController.updateValidity()}willUpdate(i){let n=i.has("value"),r=i.has("values");if(n&&r){let a=this.value==='{"en":""}',s=Object.keys(this.values).length===0;a&&!s?n=!1:!a&&s?r=!1:this.hasAttribute("values")&&!this.hasAttribute("value")?n=!1:this.hasAttribute("value")&&!this.hasAttribute("values")&&(r=!1)}if(n)try{let a=JSON.parse(this.value||"{}");JSON.stringify(a)!==JSON.stringify(this.values)&&(this.values=a)}catch(a){}if(r&&(this.value=JSON.stringify(this.values),!this._activeLanguage||!Object.prototype.hasOwnProperty.call(this.values,this._activeLanguage))){let a=Object.keys(this.values);a.length>0?this._activeLanguage=a[0]:this._activeLanguage=""}}updateValue(){this.value=JSON.stringify(this.values),this.emit("zn-change"),this.emit("zn-input")}render(){let i=Object.entries(this.languages).filter(([c])
|
|
5003
|
+
`}};_o.styles=Z(U7),y([We()],_o.prototype,"_isPlaying",2),y([_()],_o.prototype,"value",2),y([_()],_o.prototype,"label",2),y([_()],_o.prototype,"placeholder",2),y([_({type:Object})],_o.prototype,"files",2);var zoe=_o;_o.define("zn-audio-select");var G7=te`.form-control-input{margin:var(--zn-spacing-2x-small) 3px 3px}.form-control .form-control__label{display:none}.form-control .form-control__help-text{display:none}.form-control--has-label .form-control__label{display:inline-block;color:var(--zn-input-label-color);font-weight:var(--zn-font-weight-semibold);margin-bottom:var(--zn-spacing-2x-small)}.form-control--has-label.form-control--medium .form-control__label{font-size:var(--zn-input-label-font-size-medium)}.form-control--has-label.form-control--large .form-control__label{font-size:var(--zn-input-label-font-size-large)}:host([required]) .form-control--has-label .form-control__label::after{content:var(--zn-input-required-content);margin-inline-start:var(--zn-input-required-content-offset);color:var(--zn-input-required-content-color)}.form-control--has-label.form-control--radio-group .form-control__label,.form-control--has-label.form-control--checkbox-group .form-control__label{margin-bottom:0}.form-control--has-label.form-control--has-label-tooltip .form-control__label{display:inline-flex;align-items:center;gap:var(--zn-spacing-2x-small)}.form-control--has-label.form-control--small .form-control__label{font-size:var(--zn-input-label-font-size-small)}.form-control--label-tooltip{color:var(--zn-color-neutral-700);font-size:var(--zn-font-size-small)}.form-control--label-tooltip zn-icon{--icon-color:var(--zn-color-neutral-700);--icon-size:var(--zn-font-size-small)}.form-control--has-label.form-control--has-context-note{display:flex;justify-content:space-between;flex-wrap:wrap}.form-control__label-context-note{color:var(--zn-input-help-text-color);font-size:var(--zn-font-size-small);margin-bottom:var(--zn-spacing-2x-small)}.form-control--has-label.form-control--has-context-note .form-control-input{width:100%}.form-control--has-help-text .form-control__help-text,.radio--has-description .radio__description,.checkbox--has-description .checkbox__description{display:block;color:var(--zn-input-help-text-color);margin-top:var(--zn-spacing-x-small)}.radio--has-description .radio__description,.checkbox--has-description .checkbox__description{margin-top:0.375rem}.radio--has-selected-content .radio__selected-content,.checkbox--has-selected-content .checkbox__selected-content{display:block;margin-top:var(--zn-spacing-small)}.form-control--has-help-text.form-control--small .form-control__help-text{font-size:var(--zn-input-help-text-font-size-small)}.form-control--has-help-text.form-control--medium .form-control__help-text,.radio--has-description .radio__description,.checkbox--has-description .checkbox__description{font-size:var(--zn-input-help-text-font-size-medium)}.form-control--has-help-text.form-control--large .form-control__help-text{font-size:var(--zn-input-help-text-font-size-large)}.form-control--has-help-text.form-control--radio-group .form-control__help-text,.form-control--has-help-text.form-control--checkbox-group .form-control__help-text{margin-top:var(--zn-spacing-medium)}.form-control--has-help-text .switch .form-control__help-text{margin-top:var(--zn-spacing-3x-small)}.form-control--checkbox-contained-wrapper{height:100%}:host{display:block}.translations{display:flex;flex-direction:column;gap:var(--zn-spacing-small)}.input-container{padding:var(--zn-spacing-small) 0}`;var On=class extends J{constructor(){super(...arguments);this.formControlController=new rt(this);this.hasSlotController=new Ue(this,"label");this.name="";this.value='{"en":""}';this.label="";this.disabled=!1;this.required=!1;this.languages={en:"English"};this.values={};this._activeLanguage="en";this.handleLanguageAdd=i=>{let r=i.detail.element.getAttribute("data-path");r&&(this.values=et(Ce({},this.values),{[r]:""}),this._activeLanguage=r,this.updateValue())};this.handleNavbarClick=i=>{i.stopPropagation();let n=i.detail.item;if(n){let r=n.getAttribute("tab")||n.getAttribute("data-tab");r&&(this._activeLanguage=r,this.requestUpdate())}};this.handleValueUpdate=i=>{let n=i.target;if(this._activeLanguage){let r=n.value;r!==this.values[this._activeLanguage]&&(this.values=et(Ce({},this.values),{[this._activeLanguage]:r}),this.updateValue())}};this.handleKeyDown=i=>{if(i.key==="Enter"){if(i.target instanceof Tb)return;!(i.altKey||i.ctrlKey||i.metaKey||i.shiftKey)&&!i.defaultPrevented&&!i.isComposing&&this.formControlController.submit()}};this.handleSubmit=()=>{this.formControlController.submit()}}get validity(){return kn}get validationMessage(){return""}checkValidity(){return!0}getForm(){return this.formControlController.getForm()}reportValidity(){return!0}setCustomValidity(){}firstUpdated(){this.formControlController.updateValidity()}willUpdate(i){let n=i.has("value"),r=i.has("values");if(n&&r){let a=this.value==='{"en":""}',s=Object.keys(this.values).length===0;a&&!s?n=!1:!a&&s?r=!1:this.hasAttribute("values")&&!this.hasAttribute("value")?n=!1:this.hasAttribute("value")&&!this.hasAttribute("values")&&(r=!1)}if(n)try{let a=JSON.parse(this.value||"{}");JSON.stringify(a)!==JSON.stringify(this.values)&&(this.values=a)}catch(a){}if(r&&(this.value=JSON.stringify(this.values),!this._activeLanguage||!Object.prototype.hasOwnProperty.call(this.values,this._activeLanguage)&&this._activeLanguage!=="en")){let a=Object.keys(this.values);a.length>0?this._activeLanguage=a[0]:this._activeLanguage="en"}}updateValue(){this.value=JSON.stringify(this.values),this.emit("zn-change"),this.emit("zn-input")}render(){let i=Object.entries(this.languages).filter(([c])=>c!=="en"&&!Object.prototype.hasOwnProperty.call(this.values,c)).map(([c,d])=>({title:d,type:"dropdown",path:c})),n=Object.keys(this.values);n.includes("en")||n.unshift("en");let r=n.map(c=>({title:this.languages[c]||c,active:c===this._activeLanguage,tab:c})),a=this.values[this._activeLanguage],s=this.hasSlotController.test("label"),l=this.label?!0:s;return T`
|
|
5004
5004
|
<div part="form-control"
|
|
5005
5005
|
class="${ce({translations:!0,"form-control":!0,"form-control--medium":!0,"form-control--has-label":l})}"
|
|
5006
5006
|
@keydown="${this.handleKeyDown}">
|
|
@@ -5010,7 +5010,7 @@ button {
|
|
|
5010
5010
|
</label>
|
|
5011
5011
|
|
|
5012
5012
|
<zn-navbar
|
|
5013
|
-
.navigation="${
|
|
5013
|
+
.navigation="${r}"
|
|
5014
5014
|
.dropdown="${i}"
|
|
5015
5015
|
name="${this.name}-translations-navbar"
|
|
5016
5016
|
isolated
|
|
@@ -5019,24 +5019,14 @@ button {
|
|
|
5019
5019
|
manual-add-items
|
|
5020
5020
|
></zn-navbar>
|
|
5021
5021
|
<div class="input-container">
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
></zn-inline-edit>
|
|
5031
|
-
`:T`
|
|
5032
|
-
<zn-input
|
|
5033
|
-
.value="${r||""}"
|
|
5034
|
-
name="${this.name}"
|
|
5035
|
-
placeholder="Enter translation..."
|
|
5036
|
-
@zn-change="${this.handleValueUpdate}"
|
|
5037
|
-
></zn-input>
|
|
5038
|
-
`}
|
|
5039
|
-
`:""}
|
|
5022
|
+
<zn-inline-edit
|
|
5023
|
+
.value=${a}
|
|
5024
|
+
name="${this.name}"
|
|
5025
|
+
placeholder="Enter translation..."
|
|
5026
|
+
@zn-change="${this.handleValueUpdate}"
|
|
5027
|
+
@zn-input="${this.handleValueUpdate}"
|
|
5028
|
+
@zn-submit="${this.handleSubmit}"
|
|
5029
|
+
></zn-inline-edit>
|
|
5040
5030
|
</div>
|
|
5041
5031
|
</div>
|
|
5042
5032
|
`}};On.styles=Z(G7),On.dependencies={"zn-navbar":ww,"zn-input":Oc,"zn-inline-edit":Tb},y([_()],On.prototype,"name",2),y([_()],On.prototype,"value",2),y([_()],On.prototype,"label",2),y([_({type:Boolean,reflect:!0})],On.prototype,"disabled",2),y([_({type:Boolean,reflect:!0})],On.prototype,"required",2),y([_({type:Object})],On.prototype,"languages",2),y([_({type:Object})],On.prototype,"values",2),y([We()],On.prototype,"_activeLanguage",2);var Coe=On;On.define("zn-translations");})();
|
package/package.json
CHANGED
|
@@ -36,7 +36,7 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
36
36
|
};
|
|
37
37
|
@property({type: Object}) values: Record<string, string> = {};
|
|
38
38
|
|
|
39
|
-
@state() private _activeLanguage = '';
|
|
39
|
+
@state() private _activeLanguage = 'en';
|
|
40
40
|
|
|
41
41
|
get validity(): ValidityState {
|
|
42
42
|
return validValidityState;
|
|
@@ -100,12 +100,12 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
100
100
|
this.value = JSON.stringify(this.values);
|
|
101
101
|
|
|
102
102
|
// Ensure active language is valid
|
|
103
|
-
if (!this._activeLanguage || !Object.prototype.hasOwnProperty.call(this.values, this._activeLanguage)) {
|
|
103
|
+
if (!this._activeLanguage || (!Object.prototype.hasOwnProperty.call(this.values, this._activeLanguage) && this._activeLanguage !== 'en')) {
|
|
104
104
|
const keys = Object.keys(this.values);
|
|
105
105
|
if (keys.length > 0) {
|
|
106
106
|
this._activeLanguage = keys[0];
|
|
107
107
|
} else {
|
|
108
|
-
this._activeLanguage = '';
|
|
108
|
+
this._activeLanguage = 'en';
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -171,21 +171,25 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
171
171
|
|
|
172
172
|
render() {
|
|
173
173
|
const availableLanguages = Object.entries(this.languages)
|
|
174
|
-
.filter(([code]) => !Object.prototype.hasOwnProperty.call(this.values, code))
|
|
174
|
+
.filter(([code]) => code !== 'en' && !Object.prototype.hasOwnProperty.call(this.values, code))
|
|
175
175
|
.map(([code, name]) => ({
|
|
176
176
|
title: name,
|
|
177
177
|
type: 'dropdown',
|
|
178
178
|
path: code
|
|
179
179
|
}));
|
|
180
180
|
|
|
181
|
-
const
|
|
181
|
+
const visibleTabs = Object.keys(this.values);
|
|
182
|
+
if (!visibleTabs.includes('en')) {
|
|
183
|
+
visibleTabs.unshift('en');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const navigation = visibleTabs.map(code => ({
|
|
182
187
|
title: this.languages[code] || code,
|
|
183
188
|
active: code === this._activeLanguage,
|
|
184
189
|
tab: code
|
|
185
190
|
}));
|
|
186
191
|
|
|
187
192
|
const currentTranslation = this.values[this._activeLanguage];
|
|
188
|
-
const useInlineEdit = currentTranslation && currentTranslation.length > 0;
|
|
189
193
|
|
|
190
194
|
const hasLabelSlot = this.hasSlotController.test('label');
|
|
191
195
|
const hasLabel = this.label ? true : hasLabelSlot;
|
|
@@ -214,24 +218,14 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
|
|
|
214
218
|
manual-add-items
|
|
215
219
|
></zn-navbar>
|
|
216
220
|
<div class="input-container">
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
></zn-inline-edit>
|
|
226
|
-
` : html`
|
|
227
|
-
<zn-input
|
|
228
|
-
.value="${currentTranslation || ''}"
|
|
229
|
-
name="${this.name}"
|
|
230
|
-
placeholder="Enter translation..."
|
|
231
|
-
@zn-change="${this.handleValueUpdate}"
|
|
232
|
-
></zn-input>
|
|
233
|
-
`}
|
|
234
|
-
` : ''}
|
|
221
|
+
<zn-inline-edit
|
|
222
|
+
.value=${currentTranslation}
|
|
223
|
+
name="${this.name}"
|
|
224
|
+
placeholder="Enter translation..."
|
|
225
|
+
@zn-change="${this.handleValueUpdate}"
|
|
226
|
+
@zn-input="${this.handleValueUpdate}"
|
|
227
|
+
@zn-submit="${this.handleSubmit}"
|
|
228
|
+
></zn-inline-edit>
|
|
235
229
|
</div>
|
|
236
230
|
</div>
|
|
237
231
|
`;
|