@florid-kit/components 0.5.0 → 0.5.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.
@@ -5,6 +5,8 @@ export declare class OccitaneDropdown extends LitElement {
5
5
  options: {
6
6
  value: string;
7
7
  label: string;
8
+ disabled?: boolean;
9
+ url?: string;
8
10
  }[];
9
11
  value: string;
10
12
  name: string;
@@ -20,6 +22,7 @@ export declare class OccitaneDropdown extends LitElement {
20
22
  selectOption(option: {
21
23
  value: string;
22
24
  label: string;
25
+ url?: string;
23
26
  }): void;
24
27
  handleKeydown(e: KeyboardEvent): void;
25
28
  updated(changedProperties: Map<string, unknown>): void;
package/index.js CHANGED
@@ -1221,7 +1221,7 @@
1221
1221
  border-color: transparent var(--color-alpha-dark-strongest) transparent transparent;
1222
1222
  }
1223
1223
 
1224
- `;xt([a({type:String,reflect:!0})],J.prototype,"type",2);xt([a({type:String,reflect:!0})],J.prototype,"text",2);J=xt([_("o-tooltip")],J);var Je=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,E=(o,t,e,i)=>{for(var n=i>1?void 0:i?Ye(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=(i?s(t,e,n):s(n))||n);return i&&n&&Je(t,e,n),n};let x=class extends m{constructor(){super(...arguments),this.options=[],this.value="",this.name="",this.disabled=!1,this.width="100%",this.open=!1,this.activeIndex=-1,this._handleOutsideClick=o=>{this.contains(o.target)||(this.open=!1,this.activeIndex=-1)},this.menuWidth=""}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleOutsideClick)}disconnectedCallback(){document.removeEventListener("click",this._handleOutsideClick),super.disconnectedCallback()}toggle(){var o;if(!this.disabled&&(this.open=!this.open,this.activeIndex=this.open?this.options.findIndex(t=>t.value===this.value):-1,this.open&&this.width==="auto")){const t=(o=this.renderRoot)==null?void 0:o.querySelector("button");t&&(this.menuWidth=`${t.getBoundingClientRect().width}px`)}}selectOption(o){this.value=o.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value}}))}handleKeydown(o){if(this.disabled){o.preventDefault();return}if(!this.open){(o.key==="ArrowDown"||o.key==="ArrowUp")&&(o.preventDefault(),this.open=!0,this.activeIndex=this.options.findIndex(t=>t.value===this.value));return}switch(o.key){case"ArrowDown":o.preventDefault(),this.activeIndex=(this.activeIndex+1)%this.options.length;break;case"ArrowUp":o.preventDefault(),this.activeIndex=(this.activeIndex-1+this.options.length)%this.options.length;break;case"Enter":o.preventDefault(),this.activeIndex>=0&&this.selectOption(this.options[this.activeIndex]);break;case"Escape":o.preventDefault(),this.open=!1,this.activeIndex=-1;break}}updated(o){this.options.length>0&&(this.options.some(e=>e.value===this.value)||(this.value=this.options[0].value))}render(){const o=Q.checkstroke.replace("<svg",'<svg aria-hidden="true" focusable="false" part="svg"'),t=this.options.find(e=>e.value===this.value);return h`
1224
+ `;xt([a({type:String,reflect:!0})],J.prototype,"type",2);xt([a({type:String,reflect:!0})],J.prototype,"text",2);J=xt([_("o-tooltip")],J);var Je=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,E=(o,t,e,i)=>{for(var n=i>1?void 0:i?Ye(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=(i?s(t,e,n):s(n))||n);return i&&n&&Je(t,e,n),n};let x=class extends m{constructor(){super(...arguments),this.options=[],this.value="",this.name="",this.disabled=!1,this.width="100%",this.open=!1,this.activeIndex=-1,this._handleOutsideClick=o=>{this.contains(o.target)||(this.open=!1,this.activeIndex=-1)},this.menuWidth=""}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleOutsideClick)}disconnectedCallback(){document.removeEventListener("click",this._handleOutsideClick),super.disconnectedCallback()}toggle(){var o;if(!this.disabled&&(this.open=!this.open,this.activeIndex=this.open?this.options.findIndex(t=>t.value===this.value):-1,this.open&&this.width==="auto")){const t=(o=this.renderRoot)==null?void 0:o.querySelector("button");t&&(this.menuWidth=`${t.getBoundingClientRect().width}px`)}}selectOption(o){this.value=o.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value,url:o.url}}))}handleKeydown(o){if(this.disabled){o.preventDefault();return}if(!this.open){(o.key==="ArrowDown"||o.key==="ArrowUp")&&(o.preventDefault(),this.open=!0,this.activeIndex=this.options.findIndex(t=>t.value===this.value));return}switch(o.key){case"ArrowDown":o.preventDefault(),this.activeIndex=(this.activeIndex+1)%this.options.length;break;case"ArrowUp":o.preventDefault(),this.activeIndex=(this.activeIndex-1+this.options.length)%this.options.length;break;case"Enter":o.preventDefault(),this.activeIndex>=0&&this.selectOption(this.options[this.activeIndex]);break;case"Escape":o.preventDefault(),this.open=!1,this.activeIndex=-1;break}}updated(o){this.options.length>0&&(this.options.some(e=>e.value===this.value)||(this.value=this.options[0].value))}render(){const o=Q.checkstroke.replace("<svg",'<svg aria-hidden="true" focusable="false" part="svg"'),t=this.options.find(e=>e.value===this.value);return h`
1225
1225
  <button
1226
1226
  @click=${this.toggle}
1227
1227
  @keydown=${this.handleKeydown}
@@ -1242,8 +1242,8 @@
1242
1242
  <li
1243
1243
  role="option"
1244
1244
  aria-selected="${e.value===this.value}"
1245
- class="${i===this.activeIndex?"active":""}"
1246
- @click=${()=>this.selectOption(e)}
1245
+ class="${i===this.activeIndex?"active":""} ${e.disabled?"disabled":""}"
1246
+ @click=${()=>!e.disabled&&this.selectOption(e)}
1247
1247
  >
1248
1248
  <span>${e.label}</span>
1249
1249
  ${e.value===this.value?h`<span class="check">${N(o)}</span>`:null}
@@ -1290,6 +1290,7 @@
1290
1290
 
1291
1291
  &:disabled {
1292
1292
  background-color: var(--color-container-disabled);
1293
+ pointer-events: none;
1293
1294
  }
1294
1295
  }
1295
1296
 
@@ -1316,11 +1317,16 @@
1316
1317
  cursor: pointer;
1317
1318
  border-bottom: var(--border-s) solid var(--color-border-tertiary);
1318
1319
 
1319
- &:hover {
1320
+ &.disabled {
1321
+ background-color: var(--color-container-disabled);
1322
+ pointer-events: none;
1323
+ }
1324
+
1325
+ &:hover:not(.disabled) {
1320
1326
  background-color: var(--color-container-action-secondary-hover);
1321
1327
  }
1322
1328
 
1323
- &:active {
1329
+ &:active:not(.disabled) {
1324
1330
  background-color: var(--color-container-action-secondary-pressed);
1325
1331
  }
1326
1332
 
package/index.mjs CHANGED
@@ -2404,7 +2404,7 @@ let x = class extends m {
2404
2404
  }
2405
2405
  }
2406
2406
  selectOption(o) {
2407
- this.value = o.value, this.dispatchEvent(new CustomEvent("change", { detail: { value: this.value } }));
2407
+ this.value = o.value, this.dispatchEvent(new CustomEvent("change", { detail: { value: this.value, url: o.url } }));
2408
2408
  }
2409
2409
  handleKeydown(o) {
2410
2410
  if (this.disabled) {
@@ -2460,8 +2460,8 @@ let x = class extends m {
2460
2460
  <li
2461
2461
  role="option"
2462
2462
  aria-selected="${e.value === this.value}"
2463
- class="${i === this.activeIndex ? "active" : ""}"
2464
- @click=${() => this.selectOption(e)}
2463
+ class="${i === this.activeIndex ? "active" : ""} ${e.disabled ? "disabled" : ""}"
2464
+ @click=${() => !e.disabled && this.selectOption(e)}
2465
2465
  >
2466
2466
  <span>${e.label}</span>
2467
2467
  ${e.value === this.value ? h`<span class="check">${N(o)}</span>` : null}
@@ -2512,6 +2512,7 @@ x.styles = w`
2512
2512
 
2513
2513
  &:disabled {
2514
2514
  background-color: var(--color-container-disabled);
2515
+ pointer-events: none;
2515
2516
  }
2516
2517
  }
2517
2518
 
@@ -2538,11 +2539,16 @@ x.styles = w`
2538
2539
  cursor: pointer;
2539
2540
  border-bottom: var(--border-s) solid var(--color-border-tertiary);
2540
2541
 
2541
- &:hover {
2542
+ &.disabled {
2543
+ background-color: var(--color-container-disabled);
2544
+ pointer-events: none;
2545
+ }
2546
+
2547
+ &:hover:not(.disabled) {
2542
2548
  background-color: var(--color-container-action-secondary-hover);
2543
2549
  }
2544
2550
 
2545
- &:active {
2551
+ &:active:not(.disabled) {
2546
2552
  background-color: var(--color-container-action-secondary-pressed);
2547
2553
  }
2548
2554
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@florid-kit/components",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "main": "index.js",
5
5
  "module": "index.mjs",
6
6
  "typings": "index.d.ts",