New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@spectrum-web-components/action-group

Package Overview
Dependencies
Maintainers
0
Versions
313
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spectrum-web-components/action-group - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1-color-testing

12

package.json
{
"name": "@spectrum-web-components/action-group",
"version": "1.0.0",
"version": "1.0.1-color-testing",
"publishConfig": {

@@ -62,6 +62,6 @@ "access": "public"

"@lit-labs/observers": "^2.0.2",
"@spectrum-web-components/action-button": "^1.0.0",
"@spectrum-web-components/base": "^1.0.0",
"@spectrum-web-components/icons-workflow": "^1.0.0",
"@spectrum-web-components/reactive-controllers": "^1.0.0"
"@spectrum-web-components/action-button": "^1.0.1-color-testing",
"@spectrum-web-components/base": "^1.0.1-color-testing",
"@spectrum-web-components/icons-workflow": "^1.0.1-color-testing",
"@spectrum-web-components/reactive-controllers": "^1.0.1-color-testing"
},

@@ -77,3 +77,3 @@ "devDependencies": {

],
"gitHead": "5cf5d34645bf9494ebd20f64c42d1619523d2d84"
"gitHead": "17e14b4a9fa2c8b15df158ea7d77ce09bf50de82"
}

@@ -59,2 +59,5 @@ "use strict";

this.manageButtons = () => {
if (!this.slotElement) {
return;
}
const assignedElements = this.slotElement.assignedElements({

@@ -61,0 +64,0 @@ flatten: true

@@ -1,4 +0,4 @@

"use strict";var h=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var r=(c,u,e,s)=>{for(var t=s>1?void 0:s?p(u,e):u,i=c.length-1,l;i>=0;i--)(l=c[i])&&(t=(s?l(u,e,t):l(t))||t);return s&&t&&h(u,e,t),t};import{html as b,SizedMixin as f,SpectrumElement as m}from"@spectrum-web-components/base";import{property as o,query as v}from"@spectrum-web-components/base/src/decorators.js";import{RovingTabindexController as g}from"@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";import{MutationController as y}from"@lit-labs/observers/mutation-controller.js";import S from"./action-group.css.js";const d=[];export class ActionGroup extends f(m,{validSizes:["xs","s","m","l","xl"],noDefaultSize:!0}){constructor(){super();this._buttons=[];this._buttonSelector="sp-action-button, sp-action-menu";this.rovingTabindexController=new g(this,{focusInIndex:e=>{let s=-1;const t=e.findIndex((i,l)=>(!e[s]&&!i.disabled&&(s=l),i.selected&&!i.disabled));return e[t]?t:s},elements:()=>this.buttons,isFocusableElement:e=>!e.disabled});this.compact=!1;this.emphasized=!1;this.justified=!1;this.label="";this.quiet=!1;this.vertical=!1;this._selected=d;this.hasManaged=!1;this.manageButtons=()=>{const s=this.slotElement.assignedElements({flatten:!0}).reduce((t,i)=>{if(i.matches(this._buttonSelector))t.push(i);else{const l=Array.from(i.querySelectorAll(`:scope > ${this._buttonSelector}`));t.push(...l)}return t},[]);if(this.buttons=s,this.selects||!this.hasManaged){const t=[];this.buttons.forEach(i=>{i.selected&&t.push(i.value)}),this.setSelected(this.selected.concat(t))}this.manageChildren(),this.manageSelects(),this.hasManaged=!0};new y(this,{config:{childList:!0,subtree:!0},callback:()=>{this.manageButtons()},skipInitial:!0})}static get styles(){return[S]}set buttons(e){e!==this.buttons&&(this._buttons=e,this.rovingTabindexController.clearElementCache())}get buttons(){return this._buttons}set selected(e){this.requestUpdate("selected",this._selected),this._selected=e,this.updateComplete.then(()=>{this.applySelects(),this.manageChildren()})}get selected(){return this._selected}dispatchChange(e){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}))||(this.setSelected(e),this.buttons.map(t=>{t.selected=this.selected.includes(t.value)}))}setSelected(e,s){if(e===this.selected)return;const t=this.selected;this.requestUpdate("selected",t),this._selected=e,s&&this.dispatchChange(t)}focus(e){this.rovingTabindexController.focus(e)}deselectSelectedButtons(){this.buttons.forEach(e=>{e.selected&&(e.selected=!1,e.tabIndex=-1,e.setAttribute(this.selects?"aria-checked":"aria-pressed","false"))})}handleActionButtonChange(e){e.stopPropagation(),e.preventDefault()}handleClick(e){const s=e.target;if(typeof s.value!="undefined")switch(this.selects){case"single":{this.deselectSelectedButtons(),s.selected=!0,s.tabIndex=0,s.setAttribute("aria-checked","true"),this.setSelected([s.value],!0);break}case"multiple":{const t=[...this.selected];s.selected=!s.selected,s.setAttribute("aria-checked",s.selected?"true":"false"),s.selected?t.push(s.value):t.splice(this.selected.indexOf(s.value),1),this.setSelected(t,!0),this.buttons.forEach(i=>{i.tabIndex=-1}),s.tabIndex=0;break}default:break}}async applySelects(){await this.manageSelects(!0)}async manageSelects(e){if(!this.buttons.length)return;const s=this.buttons;switch(this.selects){case"single":{this.setAttribute("role","radiogroup");const t=[],i=s.map(async a=>{await a.updateComplete,a.setAttribute("role","radio"),a.setAttribute("aria-checked",a.selected?"true":"false"),a.selected&&t.push(a)});if(e)break;await Promise.all(i);const l=t.map(a=>a.value);this.setSelected(l||d);break}case"multiple":{this.getAttribute("role")==="radiogroup"&&this.removeAttribute("role");const t=[],i=[],l=s.map(async n=>{await n.updateComplete,n.setAttribute("role","checkbox"),n.setAttribute("aria-checked",n.selected?"true":"false"),n.selected&&(t.push(n.value),i.push(n))});if(e)break;await Promise.all(l);const a=t.length?t:d;this.setSelected(a);break}default:if(this.selected.length){const t=[],i=s.map(async l=>{await l.updateComplete,l.setAttribute("role","button"),l.selected?(l.setAttribute("aria-pressed","true"),t.push(l)):l.removeAttribute("aria-pressed")});if(e)break;await Promise.all(i),this.setSelected(t.map(l=>l.value))}else{this.buttons.forEach(t=>{t.setAttribute("role","button")});break}}this.hasAttribute("role")||this.setAttribute("role","toolbar")}render(){return b`
"use strict";var h=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var r=(c,u,e,s)=>{for(var t=s>1?void 0:s?p(u,e):u,i=c.length-1,l;i>=0;i--)(l=c[i])&&(t=(s?l(u,e,t):l(t))||t);return s&&t&&h(u,e,t),t};import{html as b,SizedMixin as f,SpectrumElement as m}from"@spectrum-web-components/base";import{property as o,query as v}from"@spectrum-web-components/base/src/decorators.js";import{RovingTabindexController as g}from"@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";import{MutationController as y}from"@lit-labs/observers/mutation-controller.js";import S from"./action-group.css.js";const d=[];export class ActionGroup extends f(m,{validSizes:["xs","s","m","l","xl"],noDefaultSize:!0}){constructor(){super();this._buttons=[];this._buttonSelector="sp-action-button, sp-action-menu";this.rovingTabindexController=new g(this,{focusInIndex:e=>{let s=-1;const t=e.findIndex((i,l)=>(!e[s]&&!i.disabled&&(s=l),i.selected&&!i.disabled));return e[t]?t:s},elements:()=>this.buttons,isFocusableElement:e=>!e.disabled});this.compact=!1;this.emphasized=!1;this.justified=!1;this.label="";this.quiet=!1;this.vertical=!1;this._selected=d;this.hasManaged=!1;this.manageButtons=()=>{if(!this.slotElement)return;const s=this.slotElement.assignedElements({flatten:!0}).reduce((t,i)=>{if(i.matches(this._buttonSelector))t.push(i);else{const l=Array.from(i.querySelectorAll(`:scope > ${this._buttonSelector}`));t.push(...l)}return t},[]);if(this.buttons=s,this.selects||!this.hasManaged){const t=[];this.buttons.forEach(i=>{i.selected&&t.push(i.value)}),this.setSelected(this.selected.concat(t))}this.manageChildren(),this.manageSelects(),this.hasManaged=!0};new y(this,{config:{childList:!0,subtree:!0},callback:()=>{this.manageButtons()},skipInitial:!0})}static get styles(){return[S]}set buttons(e){e!==this.buttons&&(this._buttons=e,this.rovingTabindexController.clearElementCache())}get buttons(){return this._buttons}set selected(e){this.requestUpdate("selected",this._selected),this._selected=e,this.updateComplete.then(()=>{this.applySelects(),this.manageChildren()})}get selected(){return this._selected}dispatchChange(e){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}))||(this.setSelected(e),this.buttons.map(t=>{t.selected=this.selected.includes(t.value)}))}setSelected(e,s){if(e===this.selected)return;const t=this.selected;this.requestUpdate("selected",t),this._selected=e,s&&this.dispatchChange(t)}focus(e){this.rovingTabindexController.focus(e)}deselectSelectedButtons(){this.buttons.forEach(e=>{e.selected&&(e.selected=!1,e.tabIndex=-1,e.setAttribute(this.selects?"aria-checked":"aria-pressed","false"))})}handleActionButtonChange(e){e.stopPropagation(),e.preventDefault()}handleClick(e){const s=e.target;if(typeof s.value!="undefined")switch(this.selects){case"single":{this.deselectSelectedButtons(),s.selected=!0,s.tabIndex=0,s.setAttribute("aria-checked","true"),this.setSelected([s.value],!0);break}case"multiple":{const t=[...this.selected];s.selected=!s.selected,s.setAttribute("aria-checked",s.selected?"true":"false"),s.selected?t.push(s.value):t.splice(this.selected.indexOf(s.value),1),this.setSelected(t,!0),this.buttons.forEach(i=>{i.tabIndex=-1}),s.tabIndex=0;break}default:break}}async applySelects(){await this.manageSelects(!0)}async manageSelects(e){if(!this.buttons.length)return;const s=this.buttons;switch(this.selects){case"single":{this.setAttribute("role","radiogroup");const t=[],i=s.map(async a=>{await a.updateComplete,a.setAttribute("role","radio"),a.setAttribute("aria-checked",a.selected?"true":"false"),a.selected&&t.push(a)});if(e)break;await Promise.all(i);const l=t.map(a=>a.value);this.setSelected(l||d);break}case"multiple":{this.getAttribute("role")==="radiogroup"&&this.removeAttribute("role");const t=[],i=[],l=s.map(async n=>{await n.updateComplete,n.setAttribute("role","checkbox"),n.setAttribute("aria-checked",n.selected?"true":"false"),n.selected&&(t.push(n.value),i.push(n))});if(e)break;await Promise.all(l);const a=t.length?t:d;this.setSelected(a);break}default:if(this.selected.length){const t=[],i=s.map(async l=>{await l.updateComplete,l.setAttribute("role","button"),l.selected?(l.setAttribute("aria-pressed","true"),t.push(l)):l.removeAttribute("aria-pressed")});if(e)break;await Promise.all(i),this.setSelected(t.map(l=>l.value))}else{this.buttons.forEach(t=>{t.setAttribute("role","button")});break}}this.hasAttribute("role")||this.setAttribute("role","toolbar")}render(){return b`
<slot role="presentation" @slotchange=${this.manageButtons}></slot>
`}firstUpdated(e){super.firstUpdated(e),this.addEventListener("click",this.handleClick)}updated(e){super.updated(e),e.has("selects")&&(this.manageSelects(),this.manageChildren(),this.selects?this.shadowRoot.addEventListener("change",this.handleActionButtonChange):this.shadowRoot.removeEventListener("change",this.handleActionButtonChange)),(e.has("quiet")||e.has("emphasized")||e.has("size")||e.has("staticColor"))&&this.manageChildren(e),e.has("label")&&(this.label||typeof e.get("label")!="undefined")&&(this.label.length?this.setAttribute("aria-label",this.label):this.removeAttribute("aria-label"))}manageChildren(e){this.buttons.forEach(s=>{(this.quiet||e!=null&&e.get("quiet"))&&(s.quiet=this.quiet),(this.emphasized||e!=null&&e.get("emphasized"))&&(s.emphasized=this.emphasized),(this.staticColor||e!=null&&e.get("staticColor"))&&(s.staticColor=this.staticColor),(this.selects||!this.hasManaged)&&(s.selected=this.selected.includes(s.value)),this.size&&(this.size!=="m"||typeof(e==null?void 0:e.get("size"))!="undefined")&&(s.size=this.size)})}}r([o({type:Boolean,reflect:!0})],ActionGroup.prototype,"compact",2),r([o({type:Boolean,reflect:!0})],ActionGroup.prototype,"emphasized",2),r([o({type:Boolean,reflect:!0})],ActionGroup.prototype,"justified",2),r([o({type:String})],ActionGroup.prototype,"label",2),r([o({type:Boolean,reflect:!0})],ActionGroup.prototype,"quiet",2),r([o({type:String})],ActionGroup.prototype,"selects",2),r([o({reflect:!0,attribute:"static-color"})],ActionGroup.prototype,"staticColor",2),r([o({type:Boolean,reflect:!0})],ActionGroup.prototype,"vertical",2),r([o({type:Array})],ActionGroup.prototype,"selected",1),r([v("slot")],ActionGroup.prototype,"slotElement",2);
//# sourceMappingURL=ActionGroup.js.map

@@ -39,2 +39,3 @@ "use strict";

import { isWebKit } from "@spectrum-web-components/shared";
import sinon from "sinon";
class QuietActionGroup extends LitElement {

@@ -98,2 +99,18 @@ render() {

describe("ActionGroup", () => {
it("does not throw an error if slotElement is null", async () => {
const el = await fixture(html`
<sp-action-group>
<sp-action-button value="first">First</sp-action-button>
<sp-action-button value="second">Second</sp-action-button>
</sp-action-group>
`);
const slotElementStub = sinon.stub(el, "slotElement").get(() => null);
await elementUpdated(el);
while (el.firstChild) {
el.removeChild(el.firstChild);
}
await elementUpdated(el);
expect(el.children.length).to.equal(0);
slotElementStub.restore();
});
it("loads empty action-group accessibly", async () => {

@@ -100,0 +117,0 @@ const el = await fixture(html`

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc