@simai-studio/ui 5.20261019.1921 → 5.20261020.1056
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/README.md +5 -5
- package/distr/component/button-group/css/button-group.min.css +1 -1
- package/distr/component/buttons/css/buttons.min.css +1 -1
- package/distr/component/buttons/js/buttons.min.js +1 -1
- package/distr/component/icon-buttons/css/icon-buttons.min.css +1 -1
- package/distr/component/icon-buttons/js/icon-buttons.min.js +1 -1
- package/distr/component/spinner/css/spinner.min.css +1 -1
- package/distr/component/spinner/js/spinner.min.js +1 -1
- package/distr/core/js/core-rules.js +25 -2
- package/distr/core/js/core-rules.min.js +1 -1
- package/distr/rule/js/rule.min.js +1 -1
- package/distr/rule/rule.json +24 -0
- package/distr/smart/button-group/js/button-group.min.js +13 -10
- package/distr/smart/button-group/smart.manifest.json +8 -3
- package/distr/smart/button-group/template/default.js +15 -2
- package/distr/smart/buttons/js/buttons.min.js +11 -10
- package/distr/smart/buttons/smart.manifest.json +3 -2
- package/distr/smart/buttons/template/default.js +17 -2
- package/distr/smart/icon-buttons/js/icon-buttons.min.js +11 -11
- package/distr/smart/icon-buttons/smart.manifest.json +4 -3
- package/distr/smart/icon-buttons/template/default.js +6 -2
- package/distr/smart/spinner/js/spinner.min.js +2 -2
- package/distr/smart/spinner/smart.manifest.json +36 -9
- package/distr/smart/spinner/template/default.js +4 -1
- package/package-manifest.json +26 -26
- package/package.json +5 -5
package/distr/rule/rule.json
CHANGED
|
@@ -601,6 +601,12 @@
|
|
|
601
601
|
"css": true,
|
|
602
602
|
"js": true,
|
|
603
603
|
"regex": "/class\\s*=\\s*[\"'][^\"']*\\bsf-button\\b/i",
|
|
604
|
+
"relation": [
|
|
605
|
+
{
|
|
606
|
+
"lazy": true,
|
|
607
|
+
"name": "spinner"
|
|
608
|
+
}
|
|
609
|
+
],
|
|
604
610
|
"type": "component"
|
|
605
611
|
},
|
|
606
612
|
{
|
|
@@ -731,6 +737,10 @@
|
|
|
731
737
|
},
|
|
732
738
|
{
|
|
733
739
|
"name": "cl-icons"
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
"lazy": true,
|
|
743
|
+
"name": "spinner"
|
|
734
744
|
}
|
|
735
745
|
],
|
|
736
746
|
"tags": [
|
|
@@ -754,6 +764,10 @@
|
|
|
754
764
|
},
|
|
755
765
|
{
|
|
756
766
|
"name": "cl-icons"
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
"lazy": true,
|
|
770
|
+
"name": "spinner"
|
|
757
771
|
}
|
|
758
772
|
],
|
|
759
773
|
"tags": [
|
|
@@ -1097,6 +1111,10 @@
|
|
|
1097
1111
|
},
|
|
1098
1112
|
{
|
|
1099
1113
|
"name": "pointer-events/default"
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
"lazy": true,
|
|
1117
|
+
"name": "spinner"
|
|
1100
1118
|
}
|
|
1101
1119
|
],
|
|
1102
1120
|
"tags": [
|
|
@@ -2787,6 +2805,12 @@
|
|
|
2787
2805
|
"css": true,
|
|
2788
2806
|
"js": true,
|
|
2789
2807
|
"regex": "/class\\s*=\\s*[\"'][^\"']*\\bsf-icon-button\\b/i",
|
|
2808
|
+
"relation": [
|
|
2809
|
+
{
|
|
2810
|
+
"lazy": true,
|
|
2811
|
+
"name": "spinner"
|
|
2812
|
+
}
|
|
2813
|
+
],
|
|
2790
2814
|
"type": "component"
|
|
2791
2815
|
},
|
|
2792
2816
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{"use strict";var e={"67eed2647f47"(e,t,n){n.d(t,{z:()=>i});const a=new WeakMap,s=new WeakSet;function i(e,t){const n=e.ownerDocument;s.has(n)||(n.addEventListener("reset",e=>{const t=e.target;if("FORM"!==t?.tagName)return;const n=Array.from(t.elements);setTimeout(()=>{if(!e.defaultPrevented)for(const e of n)if(e.isConnected&&e.form===t)for(const t of a.get(e)||[])t()},0)},!0),s.add(n));let i=a.get(e);return i||a.set(e,i=new Set),i.add(t),()=>i.delete(t)}},"18333410c461"(e,t,n){n.a(e,async(e,t)=>{try{var a=n("fbe0570fcc69"),s=n("2c8db2795ace"),i=n("2feae72af89f"),r=n("67eed2647f47"),o=n("0d662e4d7d63"),l=e([a,s,i,o]);[a,s,i,o]=l.then?(await l)():l;var u=n.n(a);const c={en:{group:"Theme",system:"System",light:"Light",dark:"Dark"},ru:{group:"Тема",system:"Как в системе",light:"Светлая",dark:"Тёмная"}},d=["system","light","dark"],h={system:"brightness_auto",light:"light_mode",dark:"dark_mode"};function
|
|
1
|
+
(()=>{"use strict";var e={"67eed2647f47"(e,t,n){n.d(t,{z:()=>i});const a=new WeakMap,s=new WeakSet;function i(e,t){const n=e.ownerDocument;s.has(n)||(n.addEventListener("reset",e=>{const t=e.target;if("FORM"!==t?.tagName)return;const n=Array.from(t.elements);setTimeout(()=>{if(!e.defaultPrevented)for(const e of n)if(e.isConnected&&e.form===t)for(const t of a.get(e)||[])t()},0)},!0),s.add(n));let i=a.get(e);return i||a.set(e,i=new Set),i.add(t),()=>i.delete(t)}},"50d2a204ba4c"(e,t,n){n.d(t,{le:()=>s});function a(e,t={}){const n=document.createElementNS("http://www.w3.org/2000/svg",e);return Object.entries(t).forEach(([e,t])=>{null!=t&&""!==t&&n.setAttribute(e,String(t))}),n}function s({className:e="",overlay:t=!1}={}){const n=document.createElement("span");n.className=["sf-loader-container","sf-loader--infinite",e,e&&t?`${e}--overlay`:""].filter(Boolean).join(" "),n.dataset.sfSpinnerBound="1",n.dataset.infinite="true",n.setAttribute("aria-hidden","true");const s=document.createElement("span");return s.className="sf-loader--loading-indicator",s.append(function(){const e=12,t=a("svg",{class:"sf-loader-svg",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false"}),n=a("circle",{class:"sf-loader-ring-filled",cx:e,cy:e,r:11,fill:"none",stroke:"currentColor","stroke-width":2,opacity:"0.3"}),s=a("circle",{class:"sf-loader-ring-accent",cx:e,cy:e,r:11,fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round",pathLength:100,"stroke-dasharray":"0 100",transform:"rotate(90 12 12)"});return t.append(n,s),t}()),n.append(s),n}},"18333410c461"(e,t,n){n.a(e,async(e,t)=>{try{var a=n("fbe0570fcc69"),s=n("2c8db2795ace"),i=n("2feae72af89f"),r=n("67eed2647f47"),o=n("0d662e4d7d63"),l=e([a,s,i,o]);[a,s,i,o]=l.then?(await l)():l;var u=n.n(a);const c={en:{group:"Theme",system:"System",light:"Light",dark:"Dark"},ru:{group:"Тема",system:"Как в системе",light:"Светлая",dark:"Тёмная"}},d=["system","light","dark"],h={system:"brightness_auto",light:"light_mode",dark:"dark_mode"};function f(){const e=globalThis.SF?.Loader?.themePreference;return d.includes(e)?e:"system"}function g(e=[]){if(Array.isArray(e))return e;const t=String(e||"").trim();if(!t)return[];if(t.startsWith("["))try{const e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}return t.split("|").map(e=>{const[t,n,a=""]=e.split("::"),s=a.split(",").map(e=>e.trim()).filter(Boolean),i=s.find(e=>e.startsWith("icon="));return{value:t.trim(),label:(n||t).trim(),disabled:s.includes("disabled"),loading:s.includes("loading"),icon:i?i.slice(5):""}})}function b(e=[]){const t=new Set;return g(e).map((e,n)=>{const a="string"==typeof e?{value:e,label:e}:e;if(!a||"object"!=typeof a)return null;const s=String(a.value??a.id??n).trim();return!s||t.has(s)?null:(t.add(s),{id:String(a.id||s),value:s,label:String(a.label??a.text??s),icon:String(a.icon||""),ariaLabel:String(a.ariaLabel||a["aria-label"]||""),count:null===a.count||void 0===a.count?"":String(a.count).trim(),iconOnly:Boolean((a.iconOnly??a["icon-only"])&&a.icon),loading:Boolean(a.loading),disabled:Boolean(a.disabled||a.loading)})}).filter(Boolean)}class m extends(u()){static get props(){return{templateName:{attribute:"template",default:"default"},items:{type:Array,default:[],parser:g},value:{default:""},name:{default:""},themeSwitch:{attribute:"theme-switch",type:Boolean,default:!1},size:{default:"1",values:["1/3","1/2","1","2","3"]},spacing:{type:String,default:null},tightness:{default:"",values:["","low","high","highest"]},scheme:{default:"primary",values:["primary","secondary","on-surface"]},appearance:{default:"default",values:["default","segmented"]},plate:{default:"scheme",values:["scheme","raised"]},fullWidth:{attribute:"full-width",type:Boolean,default:!1},radius:{default:"",values:["","default","square","rounded"]},orientation:{default:"horizontal",values:["horizontal","vertical"]},disabled:{type:Boolean,default:!1},ariaLabel:{attribute:"aria-label",default:""},rootClass:{attribute:"root-class",default:""}}}constructor(){super(),this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("sf-after-render",e=>{e.target!==this&&e.target.parentElement===this.querySelector(".sf-button-group")&&this.syncButtonSemantics()})}get themeSwitch(){return this.getBooleanAttr("theme-switch",!1)}get themeItems(){return d.map(e=>({value:e,label:(0,o.pageText)(c,e,this),icon:h[e],iconOnly:!0}))}get normalizedItems(){const e=b(this.themeSwitch?this.themeItems:this.getProp("items")),t=e.findIndex(e=>!e.disabled);return e.map((e,n)=>({...e,firstEnabled:n===t}))}get value(){return this.getAttribute("value")||""}set value(e){null!=e&&""!==e?this.setAttribute("value",String(e)):this.removeAttribute("value")}get disabled(){return this.getBooleanAttr("disabled",!1)}get name(){return this.getAttribute("name")||""}connectedCallback(){Object.prototype.hasOwnProperty.call(this,"_resetValue")||(this._resetValue=this.value),super.connectedCallback()}onConnected(){window.addEventListener("sf-theme-change",this.handleThemeChange),this.syncThemePreference()}onDisconnected(){window.removeEventListener("sf-theme-change",this.handleThemeChange),this._releaseReset?.(),this._releaseReset=null,this._resetInput=null,super.onDisconnected()}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),"theme-switch"===e&&t!==n&&this._isMounted&&this.syncThemePreference()}syncThemePreference(){if(!this.themeSwitch)return;const e=f();this.value!==e&&(this.value=e)}handleThemeChange=()=>this.syncThemePreference();templateContext(){return this.createTemplateContext({...this.getPropsContext(),ariaLabel:this.getAttribute("aria-label")||(this.themeSwitch?(0,o.pageText)(c,"group",this):""),...(0,i.resolveControlSpacing)({spacing:this.getAttribute("spacing"),tightness:this.getAttribute("tightness")}),component:this,items:this.normalizedItems,value:this.value,disabled:this.disabled})}template(){return(0,s.a)(this.templateContext())}emitValueChange(e){this.emitComponentEvent("button-group-change",e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{component:this,...e}}))}select(e){const t=String(e??""),n=this.normalizedItems.find(e=>e.value===t);if(!n||n.disabled||this.disabled||t===this.value)return this;const a=this.value;return this.themeSwitch&&!0!==globalThis.SF?.Loader?.setTheme?.(t)||(this.value=t,this.emitValueChange({previous:a,value:t,item:n})),this}afterRender(){this.syncButtonSemantics(),this.bindReset()}bindReset(){const e=this.querySelector(":scope > .sf-button-group-input");this._resetInput!==e&&(this._releaseReset?.(),this._resetInput=e,this._releaseReset=e?(0,r.z)(e,()=>{this.themeSwitch||(this.value=this._resetValue)}):null)}syncButtonSemantics(){const e=this.querySelector(".sf-button-group");if(!e)return;const t=this.normalizedItems,n=this.disabled?[]:t.filter(e=>!e.disabled),a=n.find(e=>e.value===this.value)||n[0];e.querySelectorAll(":scope > sf-button, :scope > button").forEach((e,n)=>{const s=e.matches("button")?e:e.querySelector("button"),i=t[n];if(!s||!i)return;const r=i.value===this.value;s.setAttribute("role","radio"),s.setAttribute("aria-checked",r?"true":"false"),s.tabIndex=i===a?0:-1})}clear(){if(!this.value||this.disabled||this.themeSwitch)return this;const e=this.value;return this.value="",this.emitValueChange({previous:e,value:"",item:null}),this}focus(e){const t=this.querySelector('button[role="radio"][tabindex="0"]:not(:disabled)');return t?.focus?.(e),this}handleClick=e=>{const t=e.target?.closest?.("[data-sf-button-group-value]");t&&this.contains(t)&&this.select(t.getAttribute("data-sf-button-group-value"))};handleKeyDown=e=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key))return;const t=this.normalizedItems.filter(e=>!e.disabled);if(!t.length||this.disabled)return;const n=Math.max(0,t.findIndex(e=>e.value===this.value)),a="Home"===e.key?0:"End"===e.key?t.length-1:["ArrowLeft","ArrowUp"].includes(e.key)?(n-1+t.length)%t.length:(n+1)%t.length;e.preventDefault();const s=this.value;this.select(t[a].value),this.value!==s&&this.addEventListener("sf-after-render",()=>this.focus(),{once:!0})}}m.define("sf-button-group"),t()}catch(p){t(p)}})},"2c8db2795ace"(e,t,n){n.a(e,async(e,a)=>{try{n.d(t,{a:()=>d});var s=n("ddf1cdb42ecc"),i=n("50d2a204ba4c"),r=e([s]),o=r.then?(await r)():r;s=o[0];function l(e,t){return t<=1?"":0===e?"start":e===t-1?"end":"middle"}function u(e,t,n){const a=e.value===n.value,i=n.disabled||e.disabled;return s.html`
|
|
2
2
|
<sf-button
|
|
3
3
|
text=${e.label}
|
|
4
4
|
icon=${e.icon||s.nothing}
|
|
@@ -6,24 +6,27 @@
|
|
|
6
6
|
spacing=${n.spacing&&"normal"!==n.spacing?n.spacing:s.nothing}
|
|
7
7
|
appearance=${a?"default":"outline"}
|
|
8
8
|
scheme=${a?n.scheme:"on-surface"}
|
|
9
|
-
segment=${
|
|
9
|
+
segment=${l(t,n.items.length)}
|
|
10
10
|
data-sf-button-group-value=${e.value}
|
|
11
11
|
aria-label=${e.ariaLabel||s.nothing}
|
|
12
12
|
class=${a?"active":s.nothing}
|
|
13
13
|
?disabled=${i}
|
|
14
|
+
?loading=${e.loading}
|
|
14
15
|
></sf-button>
|
|
15
|
-
`}function
|
|
16
|
+
`}function c(e,t){const n=e.value===t.value,a=t.disabled||e.disabled,r=["sf-button",`sf-button--size-${t.size}`,"sf-button--link","sf-button--on-surface","flex","items-cross-center","sf-button-group-segment",e.iconOnly?"sf-button-group-icon-only":"",t.spacing&&"normal"!==t.spacing?`spacing-${t.spacing}`:"",n?"active":"",e.loading?"loading sf-button-state-loading":""].filter(Boolean).join(" "),o=""!==e.count||e.ariaLabel?[e.ariaLabel||e.label,e.count].filter(e=>""!==e).join(" "):"",l=e.loading?(0,i.le)({className:"sf-button-spinner",overlay:!e.icon}):s.nothing,u=e.loading&&e.icon?l:e.icon?s.html`<sf-icon icon=${e.icon} root-class="pointer-event-none" weight="400" aria-hidden="true"></sf-icon>`:s.nothing,c=""!==e.count?s.html`<span class="sf-button-group-count">${e.count}</span>`:s.nothing;return s.html`
|
|
16
17
|
<button
|
|
17
18
|
type="button"
|
|
18
|
-
class=${
|
|
19
|
+
class=${r}
|
|
19
20
|
data-sf-button-group-value=${e.value}
|
|
20
|
-
aria-label=${
|
|
21
|
+
aria-label=${o||s.nothing}
|
|
22
|
+
aria-busy=${e.loading?"true":s.nothing}
|
|
21
23
|
?disabled=${a}
|
|
22
24
|
>
|
|
23
|
-
${
|
|
24
|
-
${
|
|
25
|
+
${e.loading&&!e.icon?l:s.nothing}
|
|
26
|
+
${u}
|
|
27
|
+
${e.iconOnly?s.html`<span class="sf-button-group-label--hidden">${e.label}</span>${c}`:s.html`<span class="sf-button-text-container text-center pointer-event-none">${e.label}${c}</span>`}
|
|
25
28
|
</button>
|
|
26
|
-
`}function
|
|
29
|
+
`}function d(e){const t="segmented"===e.appearance,n=["sf-button-group",t?"sf-button-group--segmented":"",t?`sf-button-group--size-${e.size}`:"",t&&"raised"===e.plate?"sf-button-group--plate-raised":"",t?`sf-button-group--${e.scheme}`:"",t&&e.fullWidth?"sf-button-group--full-width":"",e.radius?`sf-button-group--radius-${e.radius}`:"",e.rootClass].filter(Boolean).join(" ");return s.html`
|
|
27
30
|
<div
|
|
28
31
|
class=${n}
|
|
29
32
|
style=${e.rootStyle||s.nothing}
|
|
@@ -32,7 +35,7 @@
|
|
|
32
35
|
aria-orientation=${e.orientation}
|
|
33
36
|
data-value=${e.value||""}
|
|
34
37
|
>
|
|
35
|
-
${e.items.map((n,a)=>t?
|
|
38
|
+
${e.items.map((n,a)=>t?c(n,e):u(n,a,e))}
|
|
36
39
|
</div>
|
|
37
40
|
${e.name?s.html`<input class="sf-button-group-input" type="hidden" name=${e.name} value=${e.value||""} ?disabled=${e.disabled}>`:s.nothing}
|
|
38
|
-
`}a()}catch(
|
|
41
|
+
`}a()}catch(h){a(h)}})},"2feae72af89f"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("control-spacing"):new Promise(e=>globalThis.addEventListener("sf-runtime-ready",()=>e(globalThis.SF.runtimeModule("control-spacing")),{once:!0}))},ddf1cdb42ecc(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit"):new Promise(e=>globalThis.addEventListener("sf-runtime-ready",()=>e(globalThis.SF.runtimeModule("lit")),{once:!0}))},"0d662e4d7d63"(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("page-language"):new Promise(e=>globalThis.addEventListener("sf-runtime-ready",()=>e(globalThis.SF.runtimeModule("page-language")),{once:!0}))},fbe0570fcc69(e){e.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("smart-base"):new Promise(e=>globalThis.addEventListener("sf-runtime-ready",()=>e(globalThis.SF.runtimeModule("smart-base")),{once:!0}))}};const t={};function n(a){const s=t[a];if(void 0!==s)return s.exports;const i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}(()=>{const e="function"==typeof Symbol,t=e?Symbol("webpack queues"):"__webpack_queues__",a=e?Symbol("webpack exports"):"__webpack_exports__",s=e?Symbol("webpack error"):"__webpack_error__",i=e=>{e?.d<1&&(e.d=1,e.forEach(e=>e.r--),e.forEach(e=>e.r--?e.r++:e()))};n.a=(e,n,r)=>{let o;r&&((o=[]).d=-1);const l=new Set,u=e.exports;let c,d,h;const f=new Promise((e,t)=>{h=t,d=e});f[a]=u,f[t]=e=>(o&&e(o),l.forEach(e),f.catch(e=>{})),e.exports=f;n(e=>{let n;c=(e=>e.map(e=>{if(null!==e&&"object"==typeof e){if(e[t])return e;if(e.then){const n=[];n.d=0,e.then(e=>{r[a]=e,i(n)},e=>{r[s]=e,i(n)});const r={};return r[t]=e=>e(n),r}}const n={};return n[t]=e=>{},n[a]=e,n}))(e);const r=()=>c.map(e=>{if(e[s])throw e[s];return e[a]}),u=new Promise(e=>{n=()=>e(r),n.r=0;const a=e=>e!==o&&!l.has(e)&&(l.add(e),e&&!e.d&&(n.r++,e.push(n)));c.map(e=>e[t](a))});return n.r?u:r()},e=>(e?h(f[s]=e):d(u),i(o))),o?.d<0&&(o.d=0)}})(),n.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{if(Array.isArray(t))for(var a=0;a<t.length;){var s=t[a++],i=t[a++];n.o(e,s)?0===i&&a++:0===i?Object.defineProperty(e,s,{enumerable:!0,value:t[a++]}):Object.defineProperty(e,s,{enumerable:!0,get:i})}else for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);n("18333410c461")})();
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"composition": {
|
|
28
28
|
"uses": [
|
|
29
29
|
"component.button-group",
|
|
30
|
-
"smart.buttons"
|
|
30
|
+
"smart.buttons",
|
|
31
|
+
"component.spinner"
|
|
31
32
|
],
|
|
32
33
|
"public_parts": []
|
|
33
34
|
},
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"items": {
|
|
43
44
|
"type": "array",
|
|
44
45
|
"default": "[]",
|
|
45
|
-
"description": "Selectable items with stable value, label, icon, count, icon-only and
|
|
46
|
+
"description": "Selectable items with stable value, label, icon, count, icon-only, disabled and loading fields.",
|
|
46
47
|
"items": {
|
|
47
48
|
"type": "object",
|
|
48
49
|
"properties": {
|
|
@@ -68,6 +69,10 @@
|
|
|
68
69
|
"disabled": {
|
|
69
70
|
"type": "boolean"
|
|
70
71
|
},
|
|
72
|
+
"loading": {
|
|
73
|
+
"type": "boolean",
|
|
74
|
+
"description": "The item works: it shows the spinner at its icon's size, in place of its icon or over its label (which keeps its place and its name), says aria-busy and is disabled until the flag is cleared."
|
|
75
|
+
},
|
|
71
76
|
"count": {
|
|
72
77
|
"type": [
|
|
73
78
|
"string",
|
|
@@ -445,7 +450,7 @@
|
|
|
445
450
|
"source_artifacts": [
|
|
446
451
|
{
|
|
447
452
|
"path": "src/smart/button-group/index.js",
|
|
448
|
-
"sha256": "
|
|
453
|
+
"sha256": "2d9fcd8743768b019510b440f716345b46ca65ea069718845e6497b7de9e73bd"
|
|
449
454
|
}
|
|
450
455
|
],
|
|
451
456
|
"generated_runtime": []
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { html, nothing } from 'lit';
|
|
2
|
+
import { createInlineSpinner } from '../../../../component/spinner/js/_spinner-draw';
|
|
2
3
|
|
|
3
4
|
function segmentFor(index, total) {
|
|
4
5
|
if (total <= 1) return '';
|
|
@@ -24,6 +25,7 @@ function renderItem(item, index, context) {
|
|
|
24
25
|
aria-label=${item.ariaLabel || nothing}
|
|
25
26
|
class=${selected ? 'active' : nothing}
|
|
26
27
|
?disabled=${disabled}
|
|
28
|
+
?loading=${item.loading}
|
|
27
29
|
></sf-button>
|
|
28
30
|
`;
|
|
29
31
|
}
|
|
@@ -47,6 +49,7 @@ function renderSegment(item, context) {
|
|
|
47
49
|
item.iconOnly ? 'sf-button-group-icon-only' : '',
|
|
48
50
|
context.spacing && context.spacing !== 'normal' ? `spacing-${context.spacing}` : '',
|
|
49
51
|
selected ? 'active' : '',
|
|
52
|
+
item.loading ? 'loading sf-button-state-loading' : '',
|
|
50
53
|
].filter(Boolean).join(' ');
|
|
51
54
|
// The count stands next to the label with no space between the two nodes, so
|
|
52
55
|
// the name is composed here: the label (or the item's aria-label), then the
|
|
@@ -54,9 +57,17 @@ function renderSegment(item, context) {
|
|
|
54
57
|
const ariaLabel = item.count !== '' || item.ariaLabel
|
|
55
58
|
? [item.ariaLabel || item.label, item.count].filter((part) => part !== '').join(' ')
|
|
56
59
|
: '';
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
// A loading segment shows the spinner as a loading button does
|
|
61
|
+
// (simai/ui-source#10): in place of its icon, or over its label, which keeps
|
|
62
|
+
// its place and its name.
|
|
63
|
+
const spinner = item.loading
|
|
64
|
+
? createInlineSpinner({className: 'sf-button-spinner', overlay: !item.icon})
|
|
59
65
|
: nothing;
|
|
66
|
+
const icon = item.loading && item.icon
|
|
67
|
+
? spinner
|
|
68
|
+
: item.icon
|
|
69
|
+
? html`<sf-icon icon=${item.icon} root-class="pointer-event-none" weight="400" aria-hidden="true"></sf-icon>`
|
|
70
|
+
: nothing;
|
|
60
71
|
const count = item.count !== ''
|
|
61
72
|
? html`<span class="sf-button-group-count">${item.count}</span>`
|
|
62
73
|
: nothing;
|
|
@@ -67,8 +78,10 @@ function renderSegment(item, context) {
|
|
|
67
78
|
class=${classes}
|
|
68
79
|
data-sf-button-group-value=${item.value}
|
|
69
80
|
aria-label=${ariaLabel || nothing}
|
|
81
|
+
aria-busy=${item.loading ? 'true' : nothing}
|
|
70
82
|
?disabled=${disabled}
|
|
71
83
|
>
|
|
84
|
+
${item.loading && !item.icon ? spinner : nothing}
|
|
72
85
|
${icon}
|
|
73
86
|
${item.iconOnly
|
|
74
87
|
? html`<span class="sf-button-group-label--hidden">${item.label}</span>${count}`
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
(()=>{"use strict";var t={"06e8cd089f28"(t,e,n){function i(){const t=globalThis.SF=globalThis.SF||{};return t.__deprecationNotes instanceof Map||Object.defineProperty(t,"__deprecationNotes",{value:new Map,configurable:!0}),t.__deprecationNotes}function s({component:t="",kind:e="attribute",attribute:n="",from:s,to:o=null}={}){if(!s)return;const r=[t,e,n,s].join("|"),a=i(),c=a.get(r);if(c)c.count+=1;else if(a.set(r,{component:t,kind:e,attribute:n,from:s,to:o,count:1}),function(){const t=globalThis.document?.documentElement;return"warn"===t?.dataset?.sfDeprecations||!0===globalThis.SF?.deprecations?.warn}()){const i=t?`${t}: `:"",r="value"===e?`${n}="${s}"`:`${e} ${s}`;globalThis.console?.warn?.(`[SIMAI Framework] ${i}${r} is a legacy name${o?`; write ${o}`:""}. See contracts/changes/journal.json.`)}}if(n.d(e,{YB:()=>s}),"undefined"!=typeof globalThis){globalThis.SF=globalThis.SF||{};const t=globalThis.SF.deprecations||{};t.list=function(){return[...i().values()].map(t=>({...t}))},t.clear=function(){i().clear()},t.note=s,globalThis.SF.deprecations=t}},c76f8895b630(t,e,n){n.a(t,async(t,e)=>{try{var i=n("fbe0570fcc69"),s=n("5168bdf4a1f9"),o=n("ddf1cdb42ecc"),r=n("2feae72af89f"),a=n("06e8cd089f28"),c=t([i,s,o,r]);[i,s,o,r]=c.then?(await c)():c;var l=n.n(i);const u=new Set(["template","size","appearance","type","scheme","status","text","icon","icon-start","icon-end","icon-left","icon-right","icon-position","text-position","spacing","tightness","radius","root-class","loading","segment","disabled","native-type","aria-label","class","style","id","slot"]);function d(t,e){t?.forwardHostAttributes(e,{exclude:u,transferDataAttributes:!0,storageKey:"__sfButtonForwardedDataAttributes",targetStorageKey:"__sfButtonAttributeKeys"})}const h=["default","tonal","outline","link","surface"],g={ghost:"link"},f={danger:"error",critical:"error"};class p extends(l()){constructor(){super(),this._attributeObserver=null}static get props(){return{templateName:{attribute:"template",default:"default"},size:{default:"1"},appearance:{default:"default",aliases:["type"]},scheme:{default:"primary"},status:{default:"",values:["","error"]},textPosition:{type:String,default:"center"},text:{default:""},segment:{default:""},icon:{default:""},iconStart:{type:String,default:null},iconEnd:{type:String,default:null},iconLeft:{default:""},iconRight:{default:""},iconPosition:{default:"start"},spacing:{type:String,default:null},tightness:{default:"",values:["","low","high","highest"]},radius:{default:"",values:["","default","square","rounded"]},rootClass:{default:""},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},nativeType:{default:"button"},ariaLabel:{default:""}}}get templateName(){return this.getAttribute("template")||"default"}get size(){return this.getAttribute("size")||"1"}get appearance(){const t=this.getAttribute("appearance")||this.getAttribute("type")||"default";return Object.hasOwn(g,t)?((0,a.YB)({component:this.localName,kind:"value",attribute:"appearance",from:t,to:g[t]}),g[t]):h.includes(t)?t:"default"}get type(){return this.appearance}get scheme(){return this.getAttribute("scheme")||"primary"}get status(){const t=this.getAttribute("status")||"";return f[t]?((0,a.YB)({component:this.localName,kind:"value",attribute:"status",from:t,to:f[t]}),f[t]):t}get text(){return this.getAttribute("text")||""}get icon(){return this.getAttribute("icon")||""}get iconLeft(){return this.hasAttribute("icon-left")&&(0,a.YB)({component:this.localName,kind:"attribute",from:"icon-left",to:"icon-start"}),this.getAttribute("icon-start")??this.getAttribute("icon-left")}get iconRight(){return this.hasAttribute("icon-right")&&(0,a.YB)({component:this.localName,kind:"attribute",from:"icon-right",to:"icon-end"}),this.getAttribute("icon-end")??this.getAttribute("icon-right")}get iconStart(){return this.iconLeft}get iconEnd(){return this.iconRight}get iconPosition(){return this.getAttribute("icon-position")||"start"}noteLegacyNames(){return this.hasAttribute("tightness")&&(0,a.YB)({component:this.localName,kind:"attribute",from:"tightness",to:"spacing"}),{}}get tightness(){return(0,r.resolveControlSpacing)({spacing:this.getAttribute("spacing"),tightness:this.getAttribute("tightness")}).tightness}get spacing(){return(0,r.resolveControlSpacing)({spacing:this.getAttribute("spacing"),tightness:this.getAttribute("tightness")}).spacing}get radius(){return this.getEnumAttr("radius",["default","square","rounded"],"")}get rootClass(){return this.getAttribute("root-class")||""}get loading(){return this.getBooleanAttr("loading",!1)}get disabled(){return this.getBooleanAttr("disabled",!1)}get nativeType(){return this.getAttribute("native-type")||"button"}get ariaLabel(){return this.getAttribute("aria-label")||""}templateContext(){const t=this.getPropsContext();return this.createTemplateContext({...t,iconLeft:t.iconStart??t.iconLeft,iconRight:t.iconEnd??t.iconRight,iconStart:this.iconStart,iconEnd:this.iconEnd,type:this.type,appearance:"ghost"===t.appearance?"link":t.appearance,status:this.status,...(0,r.resolveControlSpacing)({spacing:this.getAttribute("spacing"),tightness:this.getAttribute("tightness")}),...this.noteLegacyNames?.(),component:this})}template(){return(0,s.B)(this.templateContext())}resolveUpdateMode(){return"lit"}afterRender(){d(this,this.querySelector(".sf-button")),this._attributeObserver||(this._attributeObserver=this.observeForwardedHostAttributes(()=>this.querySelector(".sf-button"),{exclude:u,transferDataAttributes:!0,storageKey:"__sfButtonForwardedDataAttributes",targetStorageKey:"__sfButtonAttributeKeys"})._forwardHostAttributeObserver)}get value(){return{template:this.templateName,size:this.size,appearance:this.appearance,type:this.type,scheme:this.scheme,status:this.status,text:this.text,icon:this.icon,iconLeft:this.iconLeft,iconRight:this.iconRight,iconStart:this.iconStart,iconEnd:this.iconEnd,iconPosition:this.iconPosition,tightness:this.tightness,spacing:this.spacing,radius:this.radius,rootClass:this.rootClass,loading:this.loading,disabled:this.disabled,nativeType:this.nativeType,ariaLabel:this.ariaLabel}}onClick(t,e){return"function"==typeof t&&this.addEventListener("click",t,e),this}onFocus(t,e){return"function"==typeof t&&this.addEventListener("focusin",t,e),this}onBlur(t,e){return"function"==typeof t&&this.addEventListener("focusout",t,e),this}onMouseEnter(t,e){return"function"==typeof t&&this.addEventListener("mouseenter",t,e),this}onMouseLeave(t,e){return"function"==typeof t&&this.addEventListener("mouseleave",t,e),this}setDisabled(t=!0){return t?this.setAttribute("disabled",""):this.removeAttribute("disabled"),this}createIcon(t){return t?o.html`<sf-icon icon="${t}" root-class="pointer-event-none" weight="400" aria-hidden="true"></sf-icon>`:""}set value(t){this.setValueAttributes(t)}onDisconnected(){this.disconnectForwardedHostAttributes(),this._attributeObserver=null,super.onDisconnected?.()}}p.define("sf-button"),e()}catch(b){e(b)}})},"5168bdf4a1f9"(t,e,n){n.a(t,async(t,i)=>{try{n.d(e,{B:()=>
|
|
1
|
+
(()=>{"use strict";var t={"50d2a204ba4c"(t,e,n){n.d(e,{le:()=>s});function i(t,e={}){const n=document.createElementNS("http://www.w3.org/2000/svg",t);return Object.entries(e).forEach(([t,e])=>{null!=e&&""!==e&&n.setAttribute(t,String(e))}),n}function s({className:t="",overlay:e=!1}={}){const n=document.createElement("span");n.className=["sf-loader-container","sf-loader--infinite",t,t&&e?`${t}--overlay`:""].filter(Boolean).join(" "),n.dataset.sfSpinnerBound="1",n.dataset.infinite="true",n.setAttribute("aria-hidden","true");const s=document.createElement("span");return s.className="sf-loader--loading-indicator",s.append(function(){const t=12,e=i("svg",{class:"sf-loader-svg",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false"}),n=i("circle",{class:"sf-loader-ring-filled",cx:t,cy:t,r:11,fill:"none",stroke:"currentColor","stroke-width":2,opacity:"0.3"}),s=i("circle",{class:"sf-loader-ring-accent",cx:t,cy:t,r:11,fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round",pathLength:100,"stroke-dasharray":"0 100",transform:"rotate(90 12 12)"});return e.append(n,s),e}()),n.append(s),n}},"06e8cd089f28"(t,e,n){function i(){const t=globalThis.SF=globalThis.SF||{};return t.__deprecationNotes instanceof Map||Object.defineProperty(t,"__deprecationNotes",{value:new Map,configurable:!0}),t.__deprecationNotes}function s({component:t="",kind:e="attribute",attribute:n="",from:s,to:o=null}={}){if(!s)return;const r=[t,e,n,s].join("|"),a=i(),c=a.get(r);if(c)c.count+=1;else if(a.set(r,{component:t,kind:e,attribute:n,from:s,to:o,count:1}),function(){const t=globalThis.document?.documentElement;return"warn"===t?.dataset?.sfDeprecations||!0===globalThis.SF?.deprecations?.warn}()){const i=t?`${t}: `:"",r="value"===e?`${n}="${s}"`:`${e} ${s}`;globalThis.console?.warn?.(`[SIMAI Framework] ${i}${r} is a legacy name${o?`; write ${o}`:""}. See contracts/changes/journal.json.`)}}if(n.d(e,{YB:()=>s}),"undefined"!=typeof globalThis){globalThis.SF=globalThis.SF||{};const t=globalThis.SF.deprecations||{};t.list=function(){return[...i().values()].map(t=>({...t}))},t.clear=function(){i().clear()},t.note=s,globalThis.SF.deprecations=t}},c76f8895b630(t,e,n){n.a(t,async(t,e)=>{try{var i=n("fbe0570fcc69"),s=n("5168bdf4a1f9"),o=n("ddf1cdb42ecc"),r=n("2feae72af89f"),a=n("06e8cd089f28"),c=t([i,s,o,r]);[i,s,o,r]=c.then?(await c)():c;var l=n.n(i);const u=new Set(["template","size","appearance","type","scheme","status","text","icon","icon-start","icon-end","icon-left","icon-right","icon-position","text-position","spacing","tightness","radius","root-class","loading","segment","disabled","native-type","aria-label","class","style","id","slot"]);function d(t,e){t?.forwardHostAttributes(e,{exclude:u,transferDataAttributes:!0,storageKey:"__sfButtonForwardedDataAttributes",targetStorageKey:"__sfButtonAttributeKeys"})}const h=["default","tonal","outline","link","surface"],g={ghost:"link"},f={danger:"error",critical:"error"};class p extends(l()){constructor(){super(),this._attributeObserver=null}static get props(){return{templateName:{attribute:"template",default:"default"},size:{default:"1"},appearance:{default:"default",aliases:["type"]},scheme:{default:"primary"},status:{default:"",values:["","error"]},textPosition:{type:String,default:"center"},text:{default:""},segment:{default:""},icon:{default:""},iconStart:{type:String,default:null},iconEnd:{type:String,default:null},iconLeft:{default:""},iconRight:{default:""},iconPosition:{default:"start"},spacing:{type:String,default:null},tightness:{default:"",values:["","low","high","highest"]},radius:{default:"",values:["","default","square","rounded"]},rootClass:{default:""},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},nativeType:{default:"button"},ariaLabel:{default:""}}}get templateName(){return this.getAttribute("template")||"default"}get size(){return this.getAttribute("size")||"1"}get appearance(){const t=this.getAttribute("appearance")||this.getAttribute("type")||"default";return Object.hasOwn(g,t)?((0,a.YB)({component:this.localName,kind:"value",attribute:"appearance",from:t,to:g[t]}),g[t]):h.includes(t)?t:"default"}get type(){return this.appearance}get scheme(){return this.getAttribute("scheme")||"primary"}get status(){const t=this.getAttribute("status")||"";return f[t]?((0,a.YB)({component:this.localName,kind:"value",attribute:"status",from:t,to:f[t]}),f[t]):t}get text(){return this.getAttribute("text")||""}get icon(){return this.getAttribute("icon")||""}get iconLeft(){return this.hasAttribute("icon-left")&&(0,a.YB)({component:this.localName,kind:"attribute",from:"icon-left",to:"icon-start"}),this.getAttribute("icon-start")??this.getAttribute("icon-left")}get iconRight(){return this.hasAttribute("icon-right")&&(0,a.YB)({component:this.localName,kind:"attribute",from:"icon-right",to:"icon-end"}),this.getAttribute("icon-end")??this.getAttribute("icon-right")}get iconStart(){return this.iconLeft}get iconEnd(){return this.iconRight}get iconPosition(){return this.getAttribute("icon-position")||"start"}noteLegacyNames(){return this.hasAttribute("tightness")&&(0,a.YB)({component:this.localName,kind:"attribute",from:"tightness",to:"spacing"}),{}}get tightness(){return(0,r.resolveControlSpacing)({spacing:this.getAttribute("spacing"),tightness:this.getAttribute("tightness")}).tightness}get spacing(){return(0,r.resolveControlSpacing)({spacing:this.getAttribute("spacing"),tightness:this.getAttribute("tightness")}).spacing}get radius(){return this.getEnumAttr("radius",["default","square","rounded"],"")}get rootClass(){return this.getAttribute("root-class")||""}get loading(){return this.getBooleanAttr("loading",!1)}get disabled(){return this.getBooleanAttr("disabled",!1)}get nativeType(){return this.getAttribute("native-type")||"button"}get ariaLabel(){return this.getAttribute("aria-label")||""}templateContext(){const t=this.getPropsContext();return this.createTemplateContext({...t,iconLeft:t.iconStart??t.iconLeft,iconRight:t.iconEnd??t.iconRight,iconStart:this.iconStart,iconEnd:this.iconEnd,type:this.type,appearance:"ghost"===t.appearance?"link":t.appearance,status:this.status,...(0,r.resolveControlSpacing)({spacing:this.getAttribute("spacing"),tightness:this.getAttribute("tightness")}),...this.noteLegacyNames?.(),component:this})}template(){return(0,s.B)(this.templateContext())}resolveUpdateMode(){return"lit"}afterRender(){d(this,this.querySelector(".sf-button")),this._attributeObserver||(this._attributeObserver=this.observeForwardedHostAttributes(()=>this.querySelector(".sf-button"),{exclude:u,transferDataAttributes:!0,storageKey:"__sfButtonForwardedDataAttributes",targetStorageKey:"__sfButtonAttributeKeys"})._forwardHostAttributeObserver)}get value(){return{template:this.templateName,size:this.size,appearance:this.appearance,type:this.type,scheme:this.scheme,status:this.status,text:this.text,icon:this.icon,iconLeft:this.iconLeft,iconRight:this.iconRight,iconStart:this.iconStart,iconEnd:this.iconEnd,iconPosition:this.iconPosition,tightness:this.tightness,spacing:this.spacing,radius:this.radius,rootClass:this.rootClass,loading:this.loading,disabled:this.disabled,nativeType:this.nativeType,ariaLabel:this.ariaLabel}}onClick(t,e){return"function"==typeof t&&this.addEventListener("click",t,e),this}onFocus(t,e){return"function"==typeof t&&this.addEventListener("focusin",t,e),this}onBlur(t,e){return"function"==typeof t&&this.addEventListener("focusout",t,e),this}onMouseEnter(t,e){return"function"==typeof t&&this.addEventListener("mouseenter",t,e),this}onMouseLeave(t,e){return"function"==typeof t&&this.addEventListener("mouseleave",t,e),this}setDisabled(t=!0){return t?this.setAttribute("disabled",""):this.removeAttribute("disabled"),this}createIcon(t){return t?o.html`<sf-icon icon="${t}" root-class="pointer-event-none" weight="400" aria-hidden="true"></sf-icon>`:""}set value(t){this.setValueAttributes(t)}onDisconnected(){this.disconnectForwardedHostAttributes(),this._attributeObserver=null,super.onDisconnected?.()}}p.define("sf-button"),e()}catch(b){e(b)}})},"5168bdf4a1f9"(t,e,n){n.a(t,async(t,i)=>{try{n.d(e,{B:()=>c});var s=n("ddf1cdb42ecc"),o=n("50d2a204ba4c"),r=t([s]),a=r.then?(await r)():r;s=a[0];function c(t){const{size:e,appearance:n,type:i,scheme:r,status:a,text:c,icon:l,iconLeft:u,iconRight:d,iconPosition:h,spacing:g,radius:f,rootClass:p,textPosition:b,loading:m,disabled:y,nativeType:S,ariaLabel:v,segment:A}=t,w=String(h||"start").toLowerCase(),x=["right","end"].includes(w),_=t.iconStart??(u||(l&&!x?l:"")),T=t.iconEnd??(d||(l&&x?l:"")),$=t.component,C=$?.hasSlotContent?.("icon-start")?$.getSlotContent("icon-start"):$?.hasSlotContent?.("icon-left")?$.getSlotContent("icon-left"):$.createIcon(_),E=$?.hasSlotContent?.("icon-end")?$.getSlotContent("icon-end"):$?.hasSlotContent?.("icon-right")?$.getSlotContent("icon-right"):$.createIcon(T),L=$?.hasSlotContent?.("text")?$.getSlotContent("text"):c,k=!C&&!E;let F=C,B=E,N="";if(m){const t=t=>(0,o.le)({className:"sf-button-spinner",overlay:t});C?F=t(!1):E?B=t(!1):N=t(!0)}const P=["sf-button",`sf-button--size-${e}`,`sf-button--${n||i}`,`sf-button--${a||r}`,"flex","items-cross-center",A?`segment-${A}`:"",g&&"normal"!==g?`spacing-${g}`:"",f?`radius-${f}`:"",p,m?"loading sf-button-state-loading":""].filter(Boolean);return s.html`
|
|
2
2
|
<button
|
|
3
|
-
type=${
|
|
4
|
-
class=${
|
|
3
|
+
type=${S}
|
|
4
|
+
class=${P.join(" ")}
|
|
5
5
|
style=${t.rootStyle||s.nothing}
|
|
6
|
-
?disabled=${m
|
|
7
|
-
aria-label=${
|
|
8
|
-
aria-busy=${
|
|
6
|
+
?disabled=${y||m}
|
|
7
|
+
aria-label=${v||s.nothing}
|
|
8
|
+
aria-busy=${m?"true":s.nothing}
|
|
9
9
|
>
|
|
10
|
-
${
|
|
10
|
+
${N}
|
|
11
|
+
${F}
|
|
11
12
|
${L?s.html`<span
|
|
12
|
-
class="sf-button-text-container text-${
|
|
13
|
+
class="sf-button-text-container text-${b} pointer-event-none${k?" flex-1":""}">
|
|
13
14
|
${L}
|
|
14
15
|
</span>`:""}
|
|
15
|
-
${
|
|
16
|
+
${B}
|
|
16
17
|
</button>
|
|
17
|
-
`}i()}catch(
|
|
18
|
+
`}i()}catch(l){i(l)}})},"2feae72af89f"(t){t.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("control-spacing"):new Promise(t=>globalThis.addEventListener("sf-runtime-ready",()=>t(globalThis.SF.runtimeModule("control-spacing")),{once:!0}))},ddf1cdb42ecc(t){t.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit"):new Promise(t=>globalThis.addEventListener("sf-runtime-ready",()=>t(globalThis.SF.runtimeModule("lit")),{once:!0}))},fbe0570fcc69(t){t.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("smart-base"):new Promise(t=>globalThis.addEventListener("sf-runtime-ready",()=>t(globalThis.SF.runtimeModule("smart-base")),{once:!0}))}};const e={};function n(i){const s=e[i];if(void 0!==s)return s.exports;const o=e[i]={exports:{}};return t[i](o,o.exports,n),o.exports}(()=>{const t="function"==typeof Symbol,e=t?Symbol("webpack queues"):"__webpack_queues__",i=t?Symbol("webpack exports"):"__webpack_exports__",s=t?Symbol("webpack error"):"__webpack_error__",o=t=>{t?.d<1&&(t.d=1,t.forEach(t=>t.r--),t.forEach(t=>t.r--?t.r++:t()))};n.a=(t,n,r)=>{let a;r&&((a=[]).d=-1);const c=new Set,l=t.exports;let u,d,h;const g=new Promise((t,e)=>{h=e,d=t});g[i]=l,g[e]=t=>(a&&t(a),c.forEach(t),g.catch(t=>{})),t.exports=g;n(t=>{let n;u=(t=>t.map(t=>{if(null!==t&&"object"==typeof t){if(t[e])return t;if(t.then){const n=[];n.d=0,t.then(t=>{r[i]=t,o(n)},t=>{r[s]=t,o(n)});const r={};return r[e]=t=>t(n),r}}const n={};return n[e]=t=>{},n[i]=t,n}))(t);const r=()=>u.map(t=>{if(t[s])throw t[s];return t[i]}),l=new Promise(t=>{n=()=>t(r),n.r=0;const i=t=>t!==a&&!c.has(t)&&(c.add(t),t&&!t.d&&(n.r++,t.push(n)));u.map(t=>t[e](i))});return n.r?l:r()},t=>(t?h(g[s]=t):d(l),o(a))),a?.d<0&&(a.d=0)}})(),n.n=t=>{const e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{if(Array.isArray(e))for(var i=0;i<e.length;){var s=e[i++],o=e[i++];n.o(t,s)?0===o&&i++:0===o?Object.defineProperty(t,s,{enumerable:!0,value:e[i++]}):Object.defineProperty(t,s,{enumerable:!0,get:o})}else for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);n("c76f8895b630")})();
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"exported_parts": [],
|
|
23
23
|
"composition": {
|
|
24
24
|
"uses": [
|
|
25
|
-
"smart.icons"
|
|
25
|
+
"smart.icons",
|
|
26
|
+
"component.spinner"
|
|
26
27
|
],
|
|
27
28
|
"public_parts": [],
|
|
28
29
|
"declarative": {
|
|
@@ -244,7 +245,7 @@
|
|
|
244
245
|
"loading": {
|
|
245
246
|
"type": "boolean",
|
|
246
247
|
"default": false,
|
|
247
|
-
"description": "Loading state
|
|
248
|
+
"description": "Loading state: the spinner at the icon's size in place of the start icon (else the end icon); without an icon it lies over the label, which keeps its place, so the width does not change. Sets aria-busy and disables the native button."
|
|
248
249
|
},
|
|
249
250
|
"disabled": {
|
|
250
251
|
"type": "boolean",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {html, nothing} from 'lit';
|
|
2
|
+
import {createInlineSpinner} from '../../../../component/spinner/js/_spinner-draw';
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
export function renderButtonTemplate(context) {
|
|
@@ -46,6 +47,19 @@ export function renderButtonTemplate(context) {
|
|
|
46
47
|
? component.getSlotContent('text')
|
|
47
48
|
: text;
|
|
48
49
|
const fullText = !leftIconContent && !rightIconContent;
|
|
50
|
+
// Loading shows the spinner at the icon's size (simai/ui-source#10): in
|
|
51
|
+
// place of the start icon, else of the end icon; a button without an icon
|
|
52
|
+
// lays it over its label, which keeps its place (and the button its width)
|
|
53
|
+
// and stays the accessible name. Icon-only is the first case.
|
|
54
|
+
let startContent = leftIconContent;
|
|
55
|
+
let endContent = rightIconContent;
|
|
56
|
+
let overlayContent = '';
|
|
57
|
+
if (loading) {
|
|
58
|
+
const spinner = (overlay) => createInlineSpinner({className: 'sf-button-spinner', overlay});
|
|
59
|
+
if (leftIconContent) startContent = spinner(false);
|
|
60
|
+
else if (rightIconContent) endContent = spinner(false);
|
|
61
|
+
else overlayContent = spinner(true);
|
|
62
|
+
}
|
|
49
63
|
const rootClasses = [
|
|
50
64
|
'sf-button',
|
|
51
65
|
`sf-button--size-${size}`,
|
|
@@ -75,12 +89,13 @@ export function renderButtonTemplate(context) {
|
|
|
75
89
|
aria-label=${ariaLabel || nothing}
|
|
76
90
|
aria-busy=${loading ? 'true' : nothing}
|
|
77
91
|
>
|
|
78
|
-
${
|
|
92
|
+
${overlayContent}
|
|
93
|
+
${startContent}
|
|
79
94
|
${textContent ? html`<span
|
|
80
95
|
class="sf-button-text-container text-${textPosition} pointer-event-none${fullText ? ' flex-1' : ''}">
|
|
81
96
|
${textContent}
|
|
82
97
|
</span>` : ''}
|
|
83
|
-
${
|
|
98
|
+
${endContent}
|
|
84
99
|
</button>
|
|
85
100
|
`;
|
|
86
101
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(()=>{"use strict";var t={"2557e7cf84cc"(t,e,s){s.a(t,async(t,e)=>{try{var
|
|
2
|
-
<sf-close root-class="pointer-event-none" size="${e||"1"}"></sf-close>`:
|
|
3
|
-
<sf-icon filled="${b}" root-class="pointer-event-none" icon="${
|
|
1
|
+
(()=>{"use strict";var t={"50d2a204ba4c"(t,e,s){s.d(e,{le:()=>r});function n(t,e={}){const s=document.createElementNS("http://www.w3.org/2000/svg",t);return Object.entries(e).forEach(([t,e])=>{null!=e&&""!==e&&s.setAttribute(t,String(e))}),s}function r({className:t="",overlay:e=!1}={}){const s=document.createElement("span");s.className=["sf-loader-container","sf-loader--infinite",t,t&&e?`${t}--overlay`:""].filter(Boolean).join(" "),s.dataset.sfSpinnerBound="1",s.dataset.infinite="true",s.setAttribute("aria-hidden","true");const r=document.createElement("span");return r.className="sf-loader--loading-indicator",r.append(function(){const t=12,e=n("svg",{class:"sf-loader-svg",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false"}),s=n("circle",{class:"sf-loader-ring-filled",cx:t,cy:t,r:11,fill:"none",stroke:"currentColor","stroke-width":2,opacity:"0.3"}),r=n("circle",{class:"sf-loader-ring-accent",cx:t,cy:t,r:11,fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round",pathLength:100,"stroke-dasharray":"0 100",transform:"rotate(90 12 12)"});return e.append(s,r),e}()),s.append(r),s}},"2557e7cf84cc"(t,e,s){s.a(t,async(t,e)=>{try{var n=s("fbe0570fcc69"),r=s("7a7da66f4cf1"),i=s("2feae72af89f"),a=t([n,r,i]);[n,r,i]=a.then?(await a)():a;var o=s.n(n);const l=new Set(["template","kind","variant","size","appearance","type","scheme","status","icon","filled","spacing","tightness","radius","segment","root-class","loading","disabled","native-type","aria-label","class","style","id","slot"]);function u(t,e){t?.forwardHostAttributes(e,{exclude:l,transferDataAttributes:!0,storageKey:"__sfIconButtonForwardedDataAttributes",targetStorageKey:"__sfIconButtonAttributeKeys"})}const c=["default","tonal","outline","link","surface","ghost"];class d extends(o()){constructor(){super(),this._attributeObserver=null}static get props(){return{templateName:{attribute:"template",default:"default"},kind:{default:"icon",values:["icon","close"],aliases:["variant"]},size:{default:"1"},appearance:{default:"default",aliases:["type"]},scheme:{default:"primary"},status:{default:"",values:["","error"]},segment:{default:""},icon:{default:"add"},filled:{type:Boolean,default:!1},spacing:{type:String,default:null},tightness:{default:"",values:["","low","high","highest"]},radius:{default:"",values:["","default","square","rounded"]},rootClass:{default:""},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},nativeType:{default:"button"},ariaLabel:{default:""}}}get templateName(){return this.getAttribute("template")||"default"}get size(){return this.getAttribute("size")||"1"}get kind(){return this.getProp("kind")}get variant(){return this.kind}get appearance(){const t=this.getAttribute("appearance")||this.getAttribute("type")||"default";return c.includes(t)?t:"default"}get type(){return this.appearance}get scheme(){return this.getAttribute("scheme")||"primary"}get status(){return this.getAttribute("status")||""}get icon(){return this.getAttribute("icon")||"add"}get segment(){return this.getEnumAttr("segment",["start","middle","end"],"")}get filled(){return this.getBooleanAttr("filled",!1)}get tightness(){return(0,i.resolveControlSpacing)({spacing:this.getAttribute("spacing"),tightness:this.getAttribute("tightness")}).tightness}get spacing(){return(0,i.resolveControlSpacing)({spacing:this.getAttribute("spacing"),tightness:this.getAttribute("tightness")}).spacing}get radius(){return this.getEnumAttr("radius",["default","square","rounded"],"")}get rootClass(){return this.getAttribute("root-class")||""}get loading(){return this.getBooleanAttr("loading",!1)}get disabled(){return this.getBooleanAttr("disabled",!1)}get nativeType(){return this.getAttribute("native-type")||"button"}get ariaLabel(){return this.getAttribute("aria-label")||""}templateContext(){const t=this.getPropsContext();return this.createTemplateContext({...t,type:this.type,variant:this.variant,...(0,i.resolveControlSpacing)({spacing:this.getAttribute("spacing"),tightness:this.getAttribute("tightness")}),component:this})}template(){return(0,r.y)(this.templateContext())}resolveUpdateMode(t=[]){const e=["disabled","aria-label","icon"];return t.length>0&&t.every(t=>e.includes(t))?"dom":"lit"}updateDom(t=[]){const e=this.querySelector(".sf-icon-button");if(!e)return!1;if(t.includes("disabled")&&(e.disabled=this.disabled||this.loading),t.includes("aria-label")&&(this.ariaLabel?e.setAttribute("aria-label",this.ariaLabel):e.removeAttribute("aria-label")),t.includes("icon")){const t=e.querySelector(".sf-icon");t&&(t.textContent=this.icon)}return u(this,e),!0}afterRender(){u(this,this.querySelector(".sf-icon-button")),this._attributeObserver||(this._attributeObserver=this.observeForwardedHostAttributes(()=>this.querySelector(".sf-icon-button"),{exclude:l,transferDataAttributes:!0,storageKey:"__sfIconButtonForwardedDataAttributes",targetStorageKey:"__sfIconButtonAttributeKeys"})._forwardHostAttributeObserver)}get value(){return{template:this.templateName,size:this.size,variant:this.variant,appearance:this.appearance,type:this.type,scheme:this.scheme,status:this.status,icon:this.icon,segment:this.segment,filled:this.filled,tightness:this.tightness,spacing:this.spacing,radius:this.radius,rootClass:this.rootClass,loading:this.loading,disabled:this.disabled,nativeType:this.nativeType,ariaLabel:this.ariaLabel}}setButtonAttributes(t={}){return this.setState({buttonAttributes:t}),this}onClick(t,e){return"function"==typeof t&&this.addEventListener("click",t,e),this}onFocus(t,e){return"function"==typeof t&&this.addEventListener("focusin",t,e),this}onBlur(t,e){return"function"==typeof t&&this.addEventListener("focusout",t,e),this}onMouseEnter(t,e){return"function"==typeof t&&this.addEventListener("mouseenter",t,e),this}onMouseLeave(t,e){return"function"==typeof t&&this.addEventListener("mouseleave",t,e),this}setDisabled(t=!0){return t?this.setAttribute("disabled",""):this.removeAttribute("disabled"),this}set value(t){this.setValueAttributes(t)}onDisconnected(){this.disconnectForwardedHostAttributes(),this._attributeObserver=null,super.onDisconnected?.()}}d.define("sf-icon-button"),e()}catch(h){e(h)}})},"7a7da66f4cf1"(t,e,s){s.a(t,async(t,n)=>{try{s.d(e,{y:()=>u});var r=s("ddf1cdb42ecc"),i=s("50d2a204ba4c"),a=t([r]),o=a.then?(await a)():a;r=o[0];const l=new Set(["1/3","1/2","1","2","3"]);function u(t){const{size:e,appearance:s,type:n,scheme:a,status:o,icon:u,segment:c,tightness:d,kind:h,variant:f,radius:g,filled:b,rootClass:p,loading:m,disabled:y,nativeType:v,ariaLabel:A}=t,S=["sf-icon-button",l.has(e||"1")?`sf-icon-button--size-${e||"1"}`:"",`sf-icon-button--${h??f??"icon"}`,`sf-icon-button--${s||n||"default"}`,"flex","items-cross-center",c?`segment-${c}`:"",`sf-icon-button--${o||a||"primary"}`,d?`tightness-${d}`:"",g?`radius-${g}`:"",p,m?"loading sf-icon-button-state-loading":""].filter(Boolean),w=m?(0,i.le)({className:"sf-icon-button-spinner"}):t.component?.hasSlotContent?.("icon")?t.component.getSlotContent("icon"):"close"===(h??f)?r.html`
|
|
2
|
+
<sf-close root-class="pointer-event-none" size="${e||"1"}"></sf-close>`:r.html`
|
|
3
|
+
<sf-icon filled="${b}" root-class="pointer-event-none" icon="${u}" weight="400" aria-hidden="true"></sf-icon>`;return r.html`
|
|
4
4
|
<button
|
|
5
|
-
type=${
|
|
6
|
-
class=${
|
|
7
|
-
style=${t.rootStyle||
|
|
8
|
-
?disabled=${m
|
|
9
|
-
aria-label=${
|
|
10
|
-
aria-busy=${
|
|
5
|
+
type=${v}
|
|
6
|
+
class=${S.join(" ")}
|
|
7
|
+
style=${t.rootStyle||r.nothing}
|
|
8
|
+
?disabled=${y||m}
|
|
9
|
+
aria-label=${A||r.nothing}
|
|
10
|
+
aria-busy=${m?"true":r.nothing}
|
|
11
11
|
>
|
|
12
|
-
${
|
|
12
|
+
${w}
|
|
13
13
|
</button>
|
|
14
|
-
`}
|
|
14
|
+
`}n()}catch(c){n(c)}})},"2feae72af89f"(t){t.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("control-spacing"):new Promise(t=>globalThis.addEventListener("sf-runtime-ready",()=>t(globalThis.SF.runtimeModule("control-spacing")),{once:!0}))},ddf1cdb42ecc(t){t.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("lit"):new Promise(t=>globalThis.addEventListener("sf-runtime-ready",()=>t(globalThis.SF.runtimeModule("lit")),{once:!0}))},fbe0570fcc69(t){t.exports=globalThis.SF&&globalThis.SF.runtimeModule?globalThis.SF.runtimeModule("smart-base"):new Promise(t=>globalThis.addEventListener("sf-runtime-ready",()=>t(globalThis.SF.runtimeModule("smart-base")),{once:!0}))}};const e={};function s(n){const r=e[n];if(void 0!==r)return r.exports;const i=e[n]={exports:{}};return t[n](i,i.exports,s),i.exports}(()=>{const t="function"==typeof Symbol,e=t?Symbol("webpack queues"):"__webpack_queues__",n=t?Symbol("webpack exports"):"__webpack_exports__",r=t?Symbol("webpack error"):"__webpack_error__",i=t=>{t?.d<1&&(t.d=1,t.forEach(t=>t.r--),t.forEach(t=>t.r--?t.r++:t()))};s.a=(t,s,a)=>{let o;a&&((o=[]).d=-1);const l=new Set,u=t.exports;let c,d,h;const f=new Promise((t,e)=>{h=e,d=t});f[n]=u,f[e]=t=>(o&&t(o),l.forEach(t),f.catch(t=>{})),t.exports=f;s(t=>{let s;c=(t=>t.map(t=>{if(null!==t&&"object"==typeof t){if(t[e])return t;if(t.then){const s=[];s.d=0,t.then(t=>{a[n]=t,i(s)},t=>{a[r]=t,i(s)});const a={};return a[e]=t=>t(s),a}}const s={};return s[e]=t=>{},s[n]=t,s}))(t);const a=()=>c.map(t=>{if(t[r])throw t[r];return t[n]}),u=new Promise(t=>{s=()=>t(a),s.r=0;const n=t=>t!==o&&!l.has(t)&&(l.add(t),t&&!t.d&&(s.r++,t.push(s)));c.map(t=>t[e](n))});return s.r?u:a()},t=>(t?h(f[r]=t):d(u),i(o))),o?.d<0&&(o.d=0)}})(),s.n=t=>{const e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{if(Array.isArray(e))for(var n=0;n<e.length;){var r=e[n++],i=e[n++];s.o(t,r)?0===i&&n++:0===i?Object.defineProperty(t,r,{enumerable:!0,value:e[n++]}):Object.defineProperty(t,r,{enumerable:!0,get:i})}else for(var r in e)s.o(e,r)&&!s.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);s("2557e7cf84cc")})();
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"uses": [
|
|
25
25
|
"component.icon-buttons",
|
|
26
26
|
"smart.icons",
|
|
27
|
-
"smart.close"
|
|
27
|
+
"smart.close",
|
|
28
|
+
"component.spinner"
|
|
28
29
|
],
|
|
29
30
|
"public_parts": []
|
|
30
31
|
},
|
|
@@ -151,7 +152,7 @@
|
|
|
151
152
|
"loading": {
|
|
152
153
|
"type": "boolean",
|
|
153
154
|
"default": false,
|
|
154
|
-
"description": "Loading state
|
|
155
|
+
"description": "Loading state: the spinner in place of the icon, at the icon's size. Sets aria-busy and disables the native button."
|
|
155
156
|
},
|
|
156
157
|
"disabled": {
|
|
157
158
|
"type": "boolean",
|
|
@@ -489,7 +490,7 @@
|
|
|
489
490
|
"source_artifacts": [
|
|
490
491
|
{
|
|
491
492
|
"path": "src/smart/icon-buttons/index.js",
|
|
492
|
-
"sha256": "
|
|
493
|
+
"sha256": "5c1408fd5125c2584f169c6803565bb053da420e5cc2d64daa1673cad72a36ce"
|
|
493
494
|
}
|
|
494
495
|
],
|
|
495
496
|
"generated_runtime": [
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {html, nothing} from 'lit';
|
|
2
2
|
import './default.css';
|
|
3
|
+
import {createInlineSpinner} from '../../../../component/spinner/js/_spinner-draw';
|
|
3
4
|
|
|
4
5
|
const ICON_BUTTON_SIZES = new Set(['1/3', '1/2', '1', '2', '3']);
|
|
5
6
|
|
|
@@ -46,8 +47,11 @@ export function renderIconButtonTemplate(context) {
|
|
|
46
47
|
loading ? 'loading sf-icon-button-state-loading' : '',
|
|
47
48
|
].filter(Boolean);
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
// Loading shows the spinner in place of the icon, at the icon's size
|
|
51
|
+
// (simai/ui-source#10); the button keeps its name and says aria-busy.
|
|
52
|
+
const iconContent = loading
|
|
53
|
+
? createInlineSpinner({className: 'sf-icon-button-spinner'})
|
|
54
|
+
: context.component?.hasSlotContent?.('icon')
|
|
51
55
|
? context.component.getSlotContent('icon')
|
|
52
56
|
: (kind ?? variant) === 'close'
|
|
53
57
|
? html`
|