@sky.ui/core 0.0.38 → 0.0.40
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/dist/custom-elements.json +2399 -2312
- package/dist/helper/controllers/animation-controller.d.ts +4 -4
- package/dist/helper/controllers/animation-controller.js.map +1 -1
- package/dist/helper/controllers/popover-controller.d.ts +11 -11
- package/dist/helper/controllers/popover-controller.js.map +1 -1
- package/dist/helper/iconify-offline.js.map +1 -1
- package/dist/helper/index.js +1 -1
- package/dist/helper/internals/form-control-base.d.ts +4 -4
- package/dist/helper/internals/form-control-base.js.map +1 -1
- package/dist/helper/utils/color-resolver.d.ts +9 -1
- package/dist/helper/utils/color-resolver.js +1 -1
- package/dist/helper/utils/color-resolver.js.map +1 -1
- package/dist/helper/utils/contrast-color.d.ts +128 -0
- package/dist/helper/utils/contrast-color.js +2 -0
- package/dist/helper/utils/contrast-color.js.map +1 -0
- package/dist/helper/utils/index.d.ts +1 -0
- package/dist/helper/utils/index.js +1 -1
- package/dist/helper/utils/size-resolver.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/sky-alert/sky-alert.d.ts +5 -5
- package/dist/sky-alert/sky-alert.js +28 -16
- package/dist/sky-alert/sky-alert.js.map +1 -1
- package/dist/sky-appbar/sky-appbar.d.ts +2 -2
- package/dist/sky-appbar/sky-appbar.js +20 -27
- package/dist/sky-appbar/sky-appbar.js.map +1 -1
- package/dist/sky-avatar/sky-avatar.d.ts +3 -3
- package/dist/sky-avatar/sky-avatar.js +8 -11
- package/dist/sky-avatar/sky-avatar.js.map +1 -1
- package/dist/sky-badge/sky-badge.d.ts +5 -5
- package/dist/sky-badge/sky-badge.js +22 -14
- package/dist/sky-badge/sky-badge.js.map +1 -1
- package/dist/sky-button/sky-button.d.ts +5 -5
- package/dist/sky-button/sky-button.js +38 -26
- package/dist/sky-button/sky-button.js.map +1 -1
- package/dist/sky-card/sky-card.d.ts +5 -5
- package/dist/sky-card/sky-card.js +20 -20
- package/dist/sky-card/sky-card.js.map +1 -1
- package/dist/sky-checkbox/sky-checkbox.d.ts +2 -2
- package/dist/sky-checkbox/sky-checkbox.js +78 -68
- package/dist/sky-checkbox/sky-checkbox.js.map +1 -1
- package/dist/sky-chip/sky-chip.d.ts +3 -3
- package/dist/sky-chip/sky-chip.js +48 -36
- package/dist/sky-chip/sky-chip.js.map +1 -1
- package/dist/sky-col/sky-col.d.ts +4 -4
- package/dist/sky-col/sky-col.js +8 -3
- package/dist/sky-col/sky-col.js.map +1 -1
- package/dist/sky-combobox/sky-combobox.d.ts +22 -9
- package/dist/sky-combobox/sky-combobox.js +792 -336
- package/dist/sky-combobox/sky-combobox.js.map +1 -1
- package/dist/sky-dialog/sky-dialog.d.ts +4 -4
- package/dist/sky-dialog/sky-dialog.js +17 -19
- package/dist/sky-dialog/sky-dialog.js.map +1 -1
- package/dist/sky-divider/sky-divider.d.ts +3 -3
- package/dist/sky-divider/sky-divider.js.map +1 -1
- package/dist/sky-flexbox/sky-flexbox.d.ts +7 -7
- package/dist/sky-flexbox/sky-flexbox.js +2 -2
- package/dist/sky-flexbox/sky-flexbox.js.map +1 -1
- package/dist/sky-flexcol/sky-flexcol.d.ts +3 -3
- package/dist/sky-flexcol/sky-flexcol.js.map +1 -1
- package/dist/sky-form/sky-form.d.ts +12 -12
- package/dist/sky-form/sky-form.js +12 -12
- package/dist/sky-form/sky-form.js.map +1 -1
- package/dist/sky-grid/sky-grid.d.ts +2 -2
- package/dist/sky-grid/sky-grid.js.map +1 -1
- package/dist/sky-icon/sky-icon.d.ts +1 -1
- package/dist/sky-icon/sky-icon.js +1 -1
- package/dist/sky-icon/sky-icon.js.map +1 -1
- package/dist/sky-image/sky-image.d.ts +5 -5
- package/dist/sky-image/sky-image.js.map +1 -1
- package/dist/sky-image/srcset-utils.js.map +1 -1
- package/dist/sky-input/sky-input.d.ts +8 -7
- package/dist/sky-input/sky-input.js +489 -202
- package/dist/sky-input/sky-input.js.map +1 -1
- package/dist/sky-list/sky-list.d.ts +4 -4
- package/dist/sky-list/sky-list.js +1 -3
- package/dist/sky-list/sky-list.js.map +1 -1
- package/dist/sky-listitem/sky-listitem.d.ts +2 -2
- package/dist/sky-listitem/sky-listitem.js +4 -7
- package/dist/sky-listitem/sky-listitem.js.map +1 -1
- package/dist/sky-radio/sky-radio.d.ts +5 -3
- package/dist/sky-radio/sky-radio.js +33 -15
- package/dist/sky-radio/sky-radio.js.map +1 -1
- package/dist/sky-row/sky-row.d.ts +2 -2
- package/dist/sky-row/sky-row.js.map +1 -1
- package/dist/sky-sheet/sky-sheet.d.ts +6 -6
- package/dist/sky-sheet/sky-sheet.js +21 -21
- package/dist/sky-sheet/sky-sheet.js.map +1 -1
- package/dist/sky-simple-table/sky-simple-table.d.ts +4 -4
- package/dist/sky-simple-table/sky-simple-table.js +4 -1
- package/dist/sky-simple-table/sky-simple-table.js.map +1 -1
- package/dist/sky-theme-provider/sky-theme-provider.d.ts +27 -27
- package/dist/sky-theme-provider/sky-theme-provider.js +1 -1
- package/dist/sky-theme-provider/sky-theme-provider.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{unsafeCSS as t,css as e,LitElement as o,nothing as i,html as r}from"lit";import{property as s,query as a,customElement as n}from"lit/decorators.js";import{when as l}from"lit/directives/when.js";import{createRef as c,ref as d}from"lit/directives/ref.js";import{resolveSemanticSurfaceKey as p,semanticSoftSurfaceTokens as h,resolveColor as g,resolveTextColorForToken as b}from"../helper/utils/color-resolver.js";import{cssOnFillEnhance as u}from"../helper/utils/contrast-color.js";import{styleMap as f}from"lit/directives/style-map.js";import{SkyIcon as y}from"../sky-icon/sky-icon.js";var m=Object.defineProperty,v=Object.getOwnPropertyDescriptor,k=(t,e,o,i)=>{for(var r,s=i>1?void 0:i?v(e,o):e,a=t.length-1;a>=0;a--)(r=t[a])&&(s=(i?r(e,o,s):r(s))||s);return i&&s&&m(e,o,s),s};const x=["default","floating","inline"],_=["circle","pill","custom"],w=["custom","top-right","top-left","bottom-left","bottom-right","top-center"];let C=class extends o{constructor(){super(...arguments),this.statusColor="success",this.textColor="default",this.iconColor="",this.position="default",this.value="",this.isIcon=!1,this.size="",this.shape="custom",this.max=99,this.hideWhenZero=!1,this.show=!0,this.offsetX="0px",this.offsetY="0px",this.ring=!1,this.ringColor="primary",this.ringOffset="1px",this.badgeLabel=null,this.badgeAriaHidden=!1,this.interactive=!1,this.placement="custom",this.badgeRef=c(),this._onActivate=t=>{this.interactive&&this.dispatchEvent(new CustomEvent("badge-click",{detail:{originalEvent:t},bubbles:!0,composed:!0}))},this._onKeydown=t=>{this.interactive&&("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this._onActivate(t)))}}updated(t){t.has("size")&&/^\d+$/.test(this.size)&&(this.size=`${this.size}px`),t.has("position")&&!x.includes(this.position)&&(this.position="default"),t.has("shape")&&!_.includes(this.shape)&&(this.shape="custom"),t.has("placement")&&!w.includes(this.placement)&&(this.placement="custom")}showBadge(){this.show=!0}hideBadge(){this.show=!1}setValue(t){this.value=t}_computeAriaLabel(t){if(this.badgeAriaHidden)return null;if(this.badgeLabel)return this.badgeLabel;if(this.isIcon)return"";if(null==t||""===t)return"Badge";const e=Number(t);return isNaN(e)?`Badge: ${t}`:`Badge count: ${t}`}_computeAnchors(t){if("custom"===t)return{top:"0",right:"0",bottom:"auto",left:"auto"};switch(t){case"top-right":default:return{top:"0",right:"0",bottom:"auto",left:"auto"};case"top-left":return{top:"0",right:"auto",bottom:"auto",left:"0"};case"bottom-left":return{top:"auto",right:"auto",bottom:"0",left:"0"};case"bottom-right":return{top:"auto",right:"0",bottom:"0",left:"auto"};case"top-center":return{top:"0",right:"auto",bottom:"auto",left:"50%"}}}_resolveBadgeSurface(){const t=p(this.statusColor);if(t){const e=h(t,{bordered:!0}),o=this.textColor&&"default"!==this.textColor?g(this.textColor):e.color;return{bg:e.bg,color:o,border:e.border}}return{bg:g(this.statusColor),color:this.textColor&&"default"!==this.textColor?g(this.textColor):b(this.statusColor),border:"none"}}render(){const t=Number(this.value),e=!isNaN(t)&&!this.isIcon,o=this.hideWhenZero&&e&&0===t,s=this.show&&!o,a=this.isIcon?null:e&&this.max>0&&t>this.max?`${this.max}+`:this.value,n=["badge",this.position];this.ring&&n.push("ringed");const c="circle"===this.shape||"pill"===this.shape?"var(--sky-radius-full)":"var(--sky-badge-radius)",h=this._resolveBadgeSurface(),b=!(p(this.statusColor)||this.textColor&&"default"!==this.textColor),{top:u,right:y,bottom:m,left:v}=this._computeAnchors(this.placement),k={"--_badge-bg":h.bg,"--_badge-text-color":h.color,"--_badge-border":h.border,"--_badge-radius":c,"--_badge-size":this.size,"--_icon-size":this.size,"--_icon-color":g(this.iconColor||this.textColor),"--_ring-color":g(this.ringColor),"--_ring-offset":this.ringOffset,"--sky-badge-translate-x":this.offsetX,"--sky-badge-translate-y":this.offsetY,"--_anchor-top":u,"--_anchor-right":y,"--_anchor-bottom":m,"--_anchor-left":v},x=this._computeAriaLabel(a);return r`
|
|
2
2
|
<div class="container" part="container">
|
|
3
3
|
<slot></slot>
|
|
4
|
-
${
|
|
4
|
+
${l(s,()=>r`
|
|
5
5
|
<span
|
|
6
|
-
class=${
|
|
6
|
+
class=${n.join(" ")}
|
|
7
7
|
part="badge"
|
|
8
|
-
style=${
|
|
8
|
+
style=${f(k)}
|
|
9
9
|
role=${this.interactive?"button":"status"}
|
|
10
10
|
aria-live=${this.interactive?"off":"polite"}
|
|
11
11
|
data-placement=${this.placement}
|
|
12
|
+
?data-solid-contrast=${b}
|
|
12
13
|
aria-atomic="true"
|
|
13
|
-
aria-label=${
|
|
14
|
+
aria-label=${x??i}
|
|
14
15
|
aria-hidden=${this.badgeAriaHidden?"true":"false"}
|
|
15
16
|
tabindex=${this.interactive?0:-1}
|
|
16
17
|
@click=${this._onActivate}
|
|
17
18
|
@keydown=${this._onKeydown}
|
|
18
|
-
${
|
|
19
|
+
${d(this.badgeRef)}
|
|
19
20
|
>
|
|
20
21
|
<slot name="badge">
|
|
21
|
-
${
|
|
22
|
+
${l(this.isIcon,()=>r`<sky-icon
|
|
23
|
+
part="icon"
|
|
24
|
+
icon=${this.value}
|
|
25
|
+
aria-hidden="true"
|
|
26
|
+
></sky-icon>`,()=>r`${a}`)}
|
|
22
27
|
</slot>
|
|
23
28
|
</span>
|
|
24
29
|
`)}
|
|
25
30
|
</div>
|
|
26
|
-
`}};
|
|
31
|
+
`}};C.dependencies={"sky-icon":y},C.shadowRootOptions={mode:"open",delegatesFocus:!0},C.styles=e`
|
|
27
32
|
:host {
|
|
28
33
|
display: inline-block;
|
|
29
34
|
position: relative;
|
|
@@ -107,7 +112,7 @@ import{css as t,LitElement as e,nothing as o,html as i}from"lit";import{property
|
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
/* Icon styling */
|
|
110
|
-
sky-icon[part=
|
|
115
|
+
sky-icon[part='icon'] {
|
|
111
116
|
display: inline-flex;
|
|
112
117
|
align-items: center;
|
|
113
118
|
justify-content: center;
|
|
@@ -120,19 +125,19 @@ import{css as t,LitElement as e,nothing as o,html as i}from"lit";import{property
|
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
/* Interactive affordances */
|
|
123
|
-
.badge[role=
|
|
128
|
+
.badge[role='button'] {
|
|
124
129
|
cursor: pointer;
|
|
125
130
|
outline: none;
|
|
126
131
|
-webkit-tap-highlight-color: transparent;
|
|
127
132
|
}
|
|
128
|
-
.badge[role=
|
|
133
|
+
.badge[role='button']:focus-visible {
|
|
129
134
|
outline: none;
|
|
130
135
|
box-shadow: var(--sky-focus-ring);
|
|
131
136
|
}
|
|
132
137
|
|
|
133
138
|
/* Ring (outline) */
|
|
134
139
|
.badge.ringed::after {
|
|
135
|
-
content:
|
|
140
|
+
content: '';
|
|
136
141
|
position: absolute;
|
|
137
142
|
inset: calc(-1 * var(--_ring-offset));
|
|
138
143
|
border-radius: inherit;
|
|
@@ -140,11 +145,14 @@ import{css as t,LitElement as e,nothing as o,html as i}from"lit";import{property
|
|
|
140
145
|
pointer-events: none;
|
|
141
146
|
}
|
|
142
147
|
|
|
143
|
-
.badge[data-placement=
|
|
148
|
+
.badge[data-placement='top-center'] {
|
|
144
149
|
transform: translate(
|
|
145
150
|
calc(-50% + var(--sky-badge-translate-x)),
|
|
146
151
|
var(--sky-badge-translate-y)
|
|
147
152
|
);
|
|
148
153
|
}
|
|
149
|
-
|
|
154
|
+
|
|
155
|
+
/* Custom solid status fills (not soft semantic surfaces). */
|
|
156
|
+
${t(u([{selector:".badge[data-solid-contrast]",fillVar:"--_badge-bg"},{selector:'.badge[data-solid-contrast] sky-icon[part="icon"]',fillVar:"--_badge-bg"}]))}
|
|
157
|
+
`,k([s({type:String,reflect:!0})],C.prototype,"statusColor",2),k([s({type:String,reflect:!0})],C.prototype,"textColor",2),k([s({type:String,reflect:!0})],C.prototype,"iconColor",2),k([s({type:String,reflect:!0})],C.prototype,"position",2),k([s({type:String})],C.prototype,"value",2),k([s({type:Boolean,reflect:!0})],C.prototype,"isIcon",2),k([s({type:String,reflect:!0})],C.prototype,"size",2),k([s({type:String,reflect:!0})],C.prototype,"shape",2),k([s({type:Number})],C.prototype,"max",2),k([s({type:Boolean})],C.prototype,"hideWhenZero",2),k([s({type:Boolean,reflect:!0})],C.prototype,"show",2),k([s({type:String})],C.prototype,"offsetX",2),k([s({type:String})],C.prototype,"offsetY",2),k([s({type:Boolean})],C.prototype,"ring",2),k([s({type:String})],C.prototype,"ringColor",2),k([s({type:String})],C.prototype,"ringOffset",2),k([s({type:String})],C.prototype,"badgeLabel",2),k([s({type:Boolean})],C.prototype,"badgeAriaHidden",2),k([s({type:Boolean})],C.prototype,"interactive",2),k([s({type:String,reflect:!0})],C.prototype,"placement",2),k([a(".badge")],C.prototype,"_badgeEl",2),C=k([n("sky-badge")],C);export{C as SkyBadge};
|
|
150
158
|
//# sourceMappingURL=sky-badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sky-badge.js","sources":["../../src/sky-badge/sky-badge.ts"],"sourcesContent":["import { LitElement, html, css, PropertyValues, nothing } from \"lit\";\r\nimport { customElement, property, query } from \"lit/decorators.js\";\r\nimport { when } from \"lit/directives/when.js\";\r\nimport { ref, createRef } from \"lit/directives/ref.js\";\r\nimport {\r\n resolveColor,\r\n resolveTextColorForToken,\r\n resolveSemanticSurfaceKey,\r\n semanticSoftSurfaceTokens,\r\n} from \"../helper/utils/color-resolver\";\r\nimport { styleMap } from \"lit/directives/style-map.js\";\r\nimport { SkyIcon } from \"../sky-icon/sky-icon.js\";\r\n\r\nexport type SkyBadgeClickEventDetail = { originalEvent: Event };\r\nexport type SkyBadgePosition = \"default\" | \"floating\" | \"inline\";\r\nexport type SkyBadgeShape = \"circle\" | \"pill\" | \"custom\";\r\nexport type SkyBadgePlacement =\r\n | \"custom\"\r\n | \"top-right\"\r\n | \"top-left\"\r\n | \"bottom-left\"\r\n | \"bottom-right\"\r\n | \"top-center\";\r\n\r\nconst SKY_BADGE_POSITIONS: readonly SkyBadgePosition[] = [\r\n \"default\",\r\n \"floating\",\r\n \"inline\",\r\n] as const;\r\nconst SKY_BADGE_SHAPES: readonly SkyBadgeShape[] = [\"circle\", \"pill\", \"custom\"] as const;\r\nconst SKY_BADGE_PLACEMENTS: readonly SkyBadgePlacement[] = [\r\n \"custom\",\r\n \"top-right\",\r\n \"top-left\",\r\n \"bottom-left\",\r\n \"bottom-right\",\r\n \"top-center\",\r\n] as const;\r\n\r\n/**\r\n * @element sky-badge\r\n *\r\n * @summary Badge for status dots, counts, or icons anchored to slotted content.\r\n *\r\n * @status stable\r\n * @since 1.0.0\r\n *\r\n * @documentation https://library.sky-ui.com/components/badge\r\n * @dependency sky-icon\r\n *\r\n * @slot - The content the badge attaches to.\r\n * @slot badge - Optional slot to override the badge content entirely.\r\n *\r\n * @fires {CustomEvent<SkyBadgeClickEventDetail>} badge-click - Emitted when badge activation occurs via click, Enter, or Space while `interactive` is true.\r\n *\r\n * @csspart container - Wrapper around the slotted content and the badge.\r\n * @csspart badge - The badge element. Use `badgeRef` for positioning (e.g. tooltip anchor).\r\n * @csspart icon - The icon element when `isIcon` is true.\r\n *\r\n * @Behavior\r\n * - Visibility is controlled by `show` and `hideWhenZero`.\r\n * - Numeric values above `max` render as `<max>+`.\r\n * - Interactive mode supports click and keyboard activation.\r\n * - Reduced motion mode removes badge transitions.\r\n *\r\n * @property {string} statusColor - Badge background token or CSS color.\r\n * @property {string} textColor - Text color token or CSS color.\r\n * @property {string} iconColor - Icon color token or CSS color; falls back to `textColor` when empty.\r\n * @property {SkyBadgePosition} position - Layout mode: `default | floating | inline`.\r\n * @property {string} value - Badge text/count or icon name in icon mode.\r\n * @property {boolean} isIcon - Renders icon mode when true.\r\n * @property {string} size - Badge and icon size CSS length.\r\n * @property {SkyBadgeShape} shape - Badge shape: `circle | pill | custom`.\r\n * @property {number} max - Maximum numeric count before rendering overflow label.\r\n * @property {boolean} hideWhenZero - Hides badge when value resolves to numeric zero.\r\n * @property {boolean} show - Forces badge visibility independent of value.\r\n * @property {string} offsetX - Horizontal offset CSS length.\r\n * @property {string} offsetY - Vertical offset CSS length.\r\n * @property {boolean} ring - Enables visual ring around the badge.\r\n * @property {string} ringColor - Ring color token or CSS color.\r\n * @property {string} ringOffset - Ring offset CSS length.\r\n * @property {string | null} badgeLabel - ARIA label override.\r\n * @property {boolean} badgeAriaHidden - Hides badge from assistive technology when true.\r\n * @property {boolean} interactive - Enables focus/activation and `badge-click` emission.\r\n * @property {SkyBadgePlacement} placement - Anchor placement preset for badge positioning.\r\n * @method showBadge Forces badge visibility on.\r\n * @method hideBadge Forces badge visibility off.\r\n * @method setValue Updates badge value text or icon name.\r\n *\r\n * @example\r\n * ```html\r\n * <sky-badge value=\"5\" statuscolor=\"danger\" placement=\"top-right\">\r\n * <sky-icon icon=\"mdi:bell-outline\"></sky-icon>\r\n * </sky-badge>\r\n * ```\r\n * ```vue\r\n * <template>\r\n * <sky-badge value=\"5\" statuscolor=\"danger\" placement=\"top-right\">\r\n * <sky-icon icon=\"mdi:bell-outline\"></sky-icon>\r\n * </sky-badge>\r\n * </template>\r\n * ```\r\n * ```jsx\r\n * export default function Demo() {\r\n * return (\r\n * <sky-badge value=\"5\" statuscolor=\"danger\" placement=\"top-right\">\r\n * <sky-icon icon=\"mdi:bell-outline\"></sky-icon>\r\n * </sky-badge>\r\n * );\r\n * }\r\n * ```\r\n */\r\n@customElement(\"sky-badge\")\r\nexport class SkyBadge extends LitElement {\r\n\r\n static dependencies: Record<string, CustomElementConstructor> = {\r\n \"sky-icon\": SkyIcon,\r\n };\r\n\r\n /** Background color of the badge. */\r\n @property({ type: String, reflect: true })\r\n statusColor: string = \"success\";\r\n\r\n /** Color of text content inside the badge. */\r\n @property({ type: String, reflect: true })\r\n textColor: string = \"default\";\r\n\r\n /** Color of the badge icon (when `isIcon` is true). */\r\n @property({ type: String, reflect: true })\r\n iconColor: string = \"\";\r\n\r\n /** Position of the badge relative to content. */\r\n @property({ type: String, reflect: true }) position: SkyBadgePosition = \"default\";\r\n\r\n /** Value or icon name displayed inside the badge. */\r\n @property({ type: String }) value: string = \"\";\r\n\r\n /** Whether the badge should render as an icon instead of text. */\r\n @property({ type: Boolean, reflect: true }) isIcon =\r\n false;\r\n\r\n /** Size (width/height) of the badge. e.g., `8px`, `1rem`. */\r\n @property({ type: String, reflect: true }) size: string = \"\";\r\n\r\n /** Shape of the badge. `circle`, `pill`, or `custom` (use `--sky-badge-radius`). */\r\n @property({ type: String, reflect: true }) shape: SkyBadgeShape = \"custom\";\r\n\r\n /** Maximum numeric count before showing e.g., `99+`. Ignored in icon mode. */\r\n @property({ type: Number }) max = 99;\r\n\r\n /** Do not render the badge if numeric value is `0`. */\r\n @property({ type: Boolean }) hideWhenZero =\r\n false;\r\n\r\n /** Controls visibility regardless of value (useful for async data). */\r\n @property({ type: Boolean, reflect: true }) show = true;\r\n\r\n /** Pixel or CSS length offsets for `default`/`floating` positions. */\r\n @property({ type: String }) offsetX: string = \"0px\";\r\n @property({ type: String }) offsetY: string = \"0px\";\r\n\r\n /** Optional outline ring around the badge. */\r\n @property({ type: Boolean }) ring = false;\r\n @property({ type: String }) ringColor: string =\r\n \"primary\";\r\n @property({ type: String }) ringOffset: string =\r\n \"1px\";\r\n\r\n /** Accessiblity: override the generated aria-label for screen readers. */\r\n @property({ type: String }) badgeLabel:\r\n | string\r\n | null = null;\r\n\r\n /** Accessibility: if true, hides the badge from assistive tech (purely decorative). */\r\n @property({ type: Boolean })\r\n badgeAriaHidden = false;\r\n\r\n /** Make badge focusable/clickable and emit `badge-click`. */\r\n @property({ type: Boolean }) interactive = false;\r\n\r\n /** Corner preset; use \"custom\" to rely on offsetX/offsetY and existing behavior. */\r\n @property({ type: String, reflect: true }) placement: SkyBadgePlacement = \"custom\";\r\n\r\n @query(\".badge\") private _badgeEl!: HTMLSpanElement;\r\n\r\n /** Ref for the badge element (e.g. for tooltip anchor or positioning). */\r\n public badgeRef = createRef<HTMLSpanElement>();\r\n\r\n static override shadowRootOptions: ShadowRootInit = {\r\n mode: \"open\",\r\n delegatesFocus: true,\r\n };\r\n\r\n static override styles = css`\r\n :host {\r\n display: inline-block;\r\n position: relative;\r\n box-sizing: border-box;\r\n /* Theming: override with --sky-badge-* for custom sizing */\r\n --sky-badge-radius: var(--sky-radius-secondary);\r\n --sky-badge-padding: var(--sky-space-0\\\\.5, 0.125rem);\r\n --sky-badge-font-size: var(--sky-font-size-xs, 0.75rem);\r\n --sky-badge-font-weight: var(--sky-font-weight-bold, 700);\r\n --sky-badge-shadow: none;\r\n --sky-badge-translate-x: 0px;\r\n --sky-badge-translate-y: 0px;\r\n }\r\n\r\n .container {\r\n display: inline-flex;\r\n position: relative;\r\n align-items: center;\r\n }\r\n\r\n /* Badge base */\r\n .badge {\r\n min-height: 5px;\r\n padding: var(--sky-badge-padding);\r\n display: inline-flex;\r\n justify-content: center;\r\n align-items: center;\r\n box-shadow: var(--sky-badge-shadow);\r\n color: var(--_badge-text-color);\r\n background-color: var(--_badge-bg);\r\n border: var(--_badge-border, none);\r\n font: var(--sky-text-caption);\r\n font-weight: var(--sky-badge-font-weight);\r\n font-size: var(--sky-badge-font-size);\r\n line-height: var(--sky-line-height-none, 1);\r\n letter-spacing: var(--sky-letter-spacing-tight, -0.01em);\r\n position: absolute;\r\n z-index: 1;\r\n border-radius: var(--_badge-radius);\r\n min-width: var(--_badge-size);\r\n min-height: var(--_badge-size);\r\n top: var(--_anchor-top, auto);\r\n right: var(--_anchor-right, auto);\r\n bottom: var(--_anchor-bottom, auto);\r\n left: var(--_anchor-left, auto);\r\n transform: translate(\r\n var(--sky-badge-translate-x),\r\n var(--sky-badge-translate-y)\r\n );\r\n user-select: none;\r\n -webkit-user-select: none;\r\n white-space: nowrap;\r\n backdrop-filter: none;\r\n -webkit-backdrop-filter: none;\r\n transition: var(--sky-transition-fast);\r\n }\r\n\r\n @media (prefers-reduced-motion: reduce) {\r\n .badge {\r\n transition: none;\r\n }\r\n }\r\n\r\n /* Floating offsets & overlap */\r\n .badge.floating {\r\n transform: translate(\r\n calc(50% + var(--sky-badge-translate-x)),\r\n calc(-50% + var(--sky-badge-translate-y))\r\n );\r\n }\r\n\r\n /* Inline style participates in text flow */\r\n .badge.inline {\r\n position: static;\r\n display: inline-flex;\r\n margin-inline-start: var(--sky-space-1\\\\.5, 6px);\r\n transform: translate(\r\n var(--sky-badge-translate-x),\r\n var(--sky-badge-translate-y)\r\n );\r\n }\r\n\r\n /* Icon styling */\r\n sky-icon[part=\"icon\"] {\r\n display: inline-flex;\r\n align-items: center;\r\n justify-content: center;\r\n width: 1em;\r\n height: 1em;\r\n font-size: var(--_icon-size);\r\n color: var(--_icon-color);\r\n backdrop-filter: none;\r\n -webkit-backdrop-filter: none;\r\n }\r\n\r\n /* Interactive affordances */\r\n .badge[role=\"button\"] {\r\n cursor: pointer;\r\n outline: none;\r\n -webkit-tap-highlight-color: transparent;\r\n }\r\n .badge[role=\"button\"]:focus-visible {\r\n outline: none;\r\n box-shadow: var(--sky-focus-ring);\r\n }\r\n\r\n /* Ring (outline) */\r\n .badge.ringed::after {\r\n content: \"\";\r\n position: absolute;\r\n inset: calc(-1 * var(--_ring-offset));\r\n border-radius: inherit;\r\n box-shadow: 0 0 0 2px var(--_ring-color);\r\n pointer-events: none;\r\n }\r\n\r\n .badge[data-placement=\"top-center\"] {\r\n transform: translate(\r\n calc(-50% + var(--sky-badge-translate-x)),\r\n var(--sky-badge-translate-y)\r\n );\r\n }\r\n `;\r\n\r\n protected override updated(changed: PropertyValues<this>): void {\r\n if (changed.has(\"size\")) {\r\n if (/^\\d+$/.test(this.size as string)) this.size = `${this.size}px`;\r\n }\r\n if (\r\n changed.has(\"position\") &&\r\n !SKY_BADGE_POSITIONS.includes(this.position)\r\n ) {\r\n this.position = \"default\";\r\n }\r\n if (changed.has(\"shape\") && !SKY_BADGE_SHAPES.includes(this.shape)) {\r\n this.shape = \"custom\";\r\n }\r\n if (\r\n changed.has(\"placement\") &&\r\n !SKY_BADGE_PLACEMENTS.includes(this.placement)\r\n ) {\r\n this.placement = \"custom\";\r\n }\r\n }\r\n\r\n /**\r\n * Forces badge visibility on.\r\n *\r\n * @returns {void}\r\n */\r\n public showBadge(): void {\r\n this.show = true;\r\n }\r\n\r\n /**\r\n * Forces badge visibility off.\r\n *\r\n * @returns {void}\r\n */\r\n public hideBadge(): void {\r\n this.show = false;\r\n }\r\n\r\n /**\r\n * Updates badge value for text/count or icon modes.\r\n *\r\n * @param value Badge value or icon name.\r\n * @returns {void}\r\n */\r\n public setValue(value: string): void {\r\n this.value = value;\r\n }\r\n\r\n /** Emits `badge-click` for interactive activation. */\r\n private _onActivate = (e: Event) => {\r\n if (!this.interactive) return;\r\n this.dispatchEvent(\r\n new CustomEvent<SkyBadgeClickEventDetail>(\"badge-click\", {\r\n detail: { originalEvent: e },\r\n bubbles: true,\r\n composed: true,\r\n })\r\n );\r\n };\r\n\r\n /** Handles keyboard activation with Enter and Space. */\r\n private _onKeydown = (e: KeyboardEvent) => {\r\n if (!this.interactive) return;\r\n if (e.key === \"Enter\" || e.key === \" \") {\r\n e.preventDefault();\r\n this._onActivate(e);\r\n }\r\n };\r\n\r\n /** Computes accessible badge label from current render state. */\r\n private _computeAriaLabel(displayValue: string | null): string | null {\r\n if (this.badgeAriaHidden) return null;\r\n if (this.badgeLabel) return this.badgeLabel;\r\n if (this.isIcon) return \"\"; // purely visual when icon unless overridden\r\n if (displayValue == null || displayValue === \"\") return \"Badge\";\r\n const n = Number(displayValue);\r\n return isNaN(n) ? `Badge: ${displayValue}` : `Badge count: ${displayValue}`;\r\n }\r\n\r\n /** Resolves anchor edges from placement preset. */\r\n private _computeAnchors(placement: SkyBadgePlacement): {\r\n top: string;\r\n right: string;\r\n bottom: string;\r\n left: string;\r\n } {\r\n if (placement === \"custom\") {\r\n return { top: \"0\", right: \"0\", bottom: \"auto\", left: \"auto\" };\r\n }\r\n switch (placement) {\r\n case \"top-right\":\r\n return { top: \"0\", right: \"0\", bottom: \"auto\", left: \"auto\" };\r\n case \"top-left\":\r\n return { top: \"0\", right: \"auto\", bottom: \"auto\", left: \"0\" };\r\n case \"bottom-left\":\r\n return { top: \"auto\", right: \"auto\", bottom: \"0\", left: \"0\" };\r\n case \"bottom-right\":\r\n return { top: \"auto\", right: \"0\", bottom: \"0\", left: \"auto\" };\r\n case \"top-center\":\r\n return { top: \"0\", right: \"auto\", bottom: \"auto\", left: \"50%\" };\r\n default:\r\n return { top: \"0\", right: \"0\", bottom: \"auto\", left: \"auto\" };\r\n }\r\n }\r\n\r\n /** Maps semantic status tokens to soft badge surface colors. */\r\n private _resolveBadgeSurface(): {\r\n bg: string;\r\n color: string;\r\n border: string;\r\n } {\r\n const semanticKey = resolveSemanticSurfaceKey(this.statusColor);\r\n if (semanticKey) {\r\n const soft = semanticSoftSurfaceTokens(semanticKey, { bordered: true });\r\n const color =\r\n this.textColor && this.textColor !== \"default\"\r\n ? resolveColor(this.textColor)\r\n : soft.color;\r\n return { bg: soft.bg, color, border: soft.border };\r\n }\r\n\r\n return {\r\n bg: resolveColor(this.statusColor),\r\n color:\r\n this.textColor && this.textColor !== \"default\"\r\n ? resolveColor(this.textColor)\r\n : resolveTextColorForToken(this.statusColor),\r\n border: \"none\",\r\n };\r\n }\r\n\r\n override render() {\r\n const numeric = Number(this.value);\r\n const isNumeric = !isNaN(numeric) && !this.isIcon;\r\n const shouldHideZero = this.hideWhenZero && isNumeric && numeric === 0;\r\n const visible = this.show && !shouldHideZero;\r\n const displayValue = this.isIcon\r\n ? null\r\n : isNumeric && this.max > 0 && numeric > this.max\r\n ? `${this.max}+`\r\n : this.value;\r\n\r\n const cls = [\"badge\", this.position];\r\n if (this.ring) cls.push(\"ringed\");\r\n\r\n const computedRadius =\r\n this.shape === \"circle\"\r\n ? \"var(--sky-radius-full)\"\r\n : this.shape === \"pill\"\r\n ? \"var(--sky-radius-full)\"\r\n : \"var(--sky-badge-radius)\";\r\n\r\n const surface = this._resolveBadgeSurface();\r\n const { top, right, bottom, left } = this._computeAnchors(this.placement);\r\n const badgeStyle = {\r\n \"--_badge-bg\": surface.bg,\r\n \"--_badge-text-color\": surface.color,\r\n \"--_badge-border\": surface.border,\r\n \"--_badge-radius\": computedRadius,\r\n \"--_badge-size\": this.size,\r\n \"--_icon-size\": this.size,\r\n \"--_icon-color\": resolveColor(this.iconColor || this.textColor),\r\n \"--_ring-color\": resolveColor(this.ringColor),\r\n \"--_ring-offset\": this.ringOffset,\r\n \"--sky-badge-translate-x\": this.offsetX,\r\n \"--sky-badge-translate-y\": this.offsetY,\r\n \"--_anchor-top\": top,\r\n \"--_anchor-right\": right,\r\n \"--_anchor-bottom\": bottom,\r\n \"--_anchor-left\": left,\r\n };\r\n\r\n const ariaLabel = this._computeAriaLabel(displayValue);\r\n\r\n return html`\r\n <div class=\"container\" part=\"container\">\r\n <slot></slot>\r\n ${when(\r\n visible,\r\n () => html`\r\n <span\r\n class=${cls.join(\" \")}\r\n part=\"badge\"\r\n style=${styleMap(badgeStyle)}\r\n role=${this.interactive ? \"button\" : \"status\"}\r\n aria-live=${this.interactive ? \"off\" : \"polite\"}\r\n data-placement=${this.placement}\r\n aria-atomic=\"true\"\r\n aria-label=${ariaLabel ?? nothing}\r\n aria-hidden=${this.badgeAriaHidden ? \"true\" : \"false\"}\r\n tabindex=${this.interactive ? 0 : -1}\r\n @click=${this._onActivate}\r\n @keydown=${this._onKeydown}\r\n ${ref(this.badgeRef)}\r\n >\r\n <slot name=\"badge\">\r\n ${when(\r\n this.isIcon,\r\n () =>\r\n html`<sky-icon part=\"icon\" icon=${this.value} aria-hidden=\"true\"></sky-icon>`,\r\n () => html`${displayValue}`,\r\n )}\r\n </slot>\r\n </span>\r\n `,\r\n )}\r\n </div>\r\n `;\r\n }\r\n}\r\n"],"names":["SKY_BADGE_POSITIONS","SKY_BADGE_SHAPES","SKY_BADGE_PLACEMENTS","SkyBadge","LitElement","constructor","super","arguments","this","statusColor","textColor","iconColor","position","value","isIcon","size","shape","max","hideWhenZero","show","offsetX","offsetY","ring","ringColor","ringOffset","badgeLabel","badgeAriaHidden","interactive","placement","badgeRef","createRef","_onActivate","e","dispatchEvent","CustomEvent","detail","originalEvent","bubbles","composed","_onKeydown","key","preventDefault","updated","changed","has","test","includes","showBadge","hideBadge","setValue","_computeAriaLabel","displayValue","n","Number","isNaN","_computeAnchors","top","right","bottom","left","_resolveBadgeSurface","semanticKey","resolveSemanticSurfaceKey","soft","semanticSoftSurfaceTokens","bordered","color","resolveColor","bg","border","resolveTextColorForToken","render","numeric","isNumeric","shouldHideZero","visible","cls","push","computedRadius","surface","badgeStyle","ariaLabel","html","when","join","styleMap","nothing","ref","dependencies","SkyIcon","shadowRootOptions","mode","delegatesFocus","styles","css","__decorateClass","property","type","String","reflect","prototype","Boolean","query","customElement"],"mappings":"2rBAwBA,MAAMA,EAAmD,CACvD,UACA,WACA,UAEIC,EAA6C,CAAC,SAAU,OAAQ,UAChEC,EAAqD,CACzD,SACA,YACA,WACA,cACA,eACA,cA6EK,IAA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G,EAsCkBiG,UAAA,eAAA,GAIeL,EAAA,CAA3CC,EAAS,CAAEC,KAAMI,QAASF,SAAS,KA1CzBhG,EA0CiCiG,UAAA,OAAA,GAGhBL,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,UA7CP/F,EA6CiBiG,UAAA,UAAA,GACAL,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,UA9CP/F,EA8CiBiG,UAAA,UAAA,GAGCL,EAAA,CAA5BC,EAAS,CAAEC,KAAMI,WAjDPlG,EAiDkBiG,UAAA,OAAA,GACDL,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,UAlDP/F,EAkDiBiG,UAAA,YAAA,GAEAL,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,UApDP/F,EAoDiBiG,UAAA,aAAA,GAIAL,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,UAxDP/F,EAwDiBiG,UAAA,aAAA,GAM5BL,EAAA,CADCC,EAAS,CAAEC,KAAMI,WA7DPlG,EA8DXiG,UAAA,kBAAA,GAG6BL,EAAA,CAA5BC,EAAS,CAAEC,KAAMI,WAjEPlG,EAiEkBiG,UAAA,cAAA,GAGcL,EAAA,CAA1CC,EAAS,CAAEC,KAAMC,OAAQC,SAAS,KApExBhG,EAoEgCiG,UAAA,YAAA,GAElBL,EAAA,CAAxBO,EAAM,WAtEInG,EAsEciG,UAAA,WAAA,GAtEdjG,EAAN4F,EAAA,CADNQ,EAAc,cACFpG"}
|
|
1
|
+
{"version":3,"file":"sky-badge.js","sources":["../../src/sky-badge/sky-badge.ts"],"sourcesContent":["import { LitElement, html, css, PropertyValues, nothing, unsafeCSS } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { when } from 'lit/directives/when.js';\nimport { ref, createRef } from 'lit/directives/ref.js';\nimport {\n resolveColor,\n resolveTextColorForToken,\n resolveSemanticSurfaceKey,\n semanticSoftSurfaceTokens,\n} from '../helper/utils/color-resolver';\nimport { cssOnFillEnhance } from '../helper/utils/contrast-color';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { SkyIcon } from '../sky-icon/sky-icon.js';\n\nexport type SkyBadgeClickEventDetail = { originalEvent: Event };\nexport type SkyBadgePosition = 'default' | 'floating' | 'inline';\nexport type SkyBadgeShape = 'circle' | 'pill' | 'custom';\nexport type SkyBadgePlacement =\n | 'custom'\n | 'top-right'\n | 'top-left'\n | 'bottom-left'\n | 'bottom-right'\n | 'top-center';\n\nconst SKY_BADGE_POSITIONS: readonly SkyBadgePosition[] = [\n 'default',\n 'floating',\n 'inline',\n] as const;\nconst SKY_BADGE_SHAPES: readonly SkyBadgeShape[] = [\n 'circle',\n 'pill',\n 'custom',\n] as const;\nconst SKY_BADGE_PLACEMENTS: readonly SkyBadgePlacement[] = [\n 'custom',\n 'top-right',\n 'top-left',\n 'bottom-left',\n 'bottom-right',\n 'top-center',\n] as const;\n\n/**\n * @element sky-badge\n *\n * @summary Badge for status dots, counts, or icons anchored to slotted content.\n *\n * @status stable\n * @since 1.0.0\n *\n * @documentation https://sky-ui.com/components/badge\n * @dependency sky-icon\n *\n * @slot - The content the badge attaches to.\n * @slot badge - Optional slot to override the badge content entirely.\n *\n * @fires {CustomEvent<SkyBadgeClickEventDetail>} badge-click - Emitted when badge activation occurs via click, Enter, or Space while `interactive` is true.\n *\n * @csspart container - Wrapper around the slotted content and the badge.\n * @csspart badge - The badge element. Use `badgeRef` for positioning (e.g. tooltip anchor).\n * @csspart icon - The icon element when `isIcon` is true.\n *\n * @Behavior\n * - Visibility is controlled by `show` and `hideWhenZero`.\n * - Numeric values above `max` render as `<max>+`.\n * - Interactive mode supports click and keyboard activation.\n * - Reduced motion mode removes badge transitions.\n *\n * @property {string} statusColor - Badge background token or CSS color.\n * @property {string} textColor - Text color token or CSS color.\n * @property {string} iconColor - Icon color token or CSS color; falls back to `textColor` when empty.\n * @property {SkyBadgePosition} position - Layout mode: `default | floating | inline`.\n * @property {string} value - Badge text/count or icon name in icon mode.\n * @property {boolean} isIcon - Renders icon mode when true.\n * @property {string} size - Badge and icon size CSS length.\n * @property {SkyBadgeShape} shape - Badge shape: `circle | pill | custom`.\n * @property {number} max - Maximum numeric count before rendering overflow label.\n * @property {boolean} hideWhenZero - Hides badge when value resolves to numeric zero.\n * @property {boolean} show - Forces badge visibility independent of value.\n * @property {string} offsetX - Horizontal offset CSS length.\n * @property {string} offsetY - Vertical offset CSS length.\n * @property {boolean} ring - Enables visual ring around the badge.\n * @property {string} ringColor - Ring color token or CSS color.\n * @property {string} ringOffset - Ring offset CSS length.\n * @property {string | null} badgeLabel - ARIA label override.\n * @property {boolean} badgeAriaHidden - Hides badge from assistive technology when true.\n * @property {boolean} interactive - Enables focus/activation and `badge-click` emission.\n * @property {SkyBadgePlacement} placement - Anchor placement preset for badge positioning.\n * @method showBadge Forces badge visibility on.\n * @method hideBadge Forces badge visibility off.\n * @method setValue Updates badge value text or icon name.\n *\n * @example\n * ```html\n * <sky-badge value=\"5\" statuscolor=\"danger\" placement=\"top-right\">\n * <sky-icon icon=\"mdi:bell-outline\"></sky-icon>\n * </sky-badge>\n * ```\n * ```vue\n * <template>\n * <sky-badge value=\"5\" statuscolor=\"danger\" placement=\"top-right\">\n * <sky-icon icon=\"mdi:bell-outline\"></sky-icon>\n * </sky-badge>\n * </template>\n * ```\n * ```jsx\n * export default function Demo() {\n * return (\n * <sky-badge value=\"5\" statuscolor=\"danger\" placement=\"top-right\">\n * <sky-icon icon=\"mdi:bell-outline\"></sky-icon>\n * </sky-badge>\n * );\n * }\n * ```\n */\n@customElement('sky-badge')\nexport class SkyBadge extends LitElement {\n static dependencies: Record<string, CustomElementConstructor> = {\n 'sky-icon': SkyIcon,\n };\n\n /** Background color of the badge. */\n @property({ type: String, reflect: true })\n statusColor: string = 'success';\n\n /** Color of text content inside the badge. */\n @property({ type: String, reflect: true })\n textColor: string = 'default';\n\n /** Color of the badge icon (when `isIcon` is true). */\n @property({ type: String, reflect: true })\n iconColor: string = '';\n\n /** Position of the badge relative to content. */\n @property({ type: String, reflect: true }) position: SkyBadgePosition =\n 'default';\n\n /** Value or icon name displayed inside the badge. */\n @property({ type: String }) value: string = '';\n\n /** Whether the badge should render as an icon instead of text. */\n @property({ type: Boolean, reflect: true }) isIcon = false;\n\n /** Size (width/height) of the badge. e.g., `8px`, `1rem`. */\n @property({ type: String, reflect: true }) size: string = '';\n\n /** Shape of the badge. `circle`, `pill`, or `custom` (use `--sky-badge-radius`). */\n @property({ type: String, reflect: true }) shape: SkyBadgeShape = 'custom';\n\n /** Maximum numeric count before showing e.g., `99+`. Ignored in icon mode. */\n @property({ type: Number }) max = 99;\n\n /** Do not render the badge if numeric value is `0`. */\n @property({ type: Boolean }) hideWhenZero = false;\n\n /** Controls visibility regardless of value (useful for async data). */\n @property({ type: Boolean, reflect: true }) show = true;\n\n /** Pixel or CSS length offsets for `default`/`floating` positions. */\n @property({ type: String }) offsetX: string = '0px';\n @property({ type: String }) offsetY: string = '0px';\n\n /** Optional outline ring around the badge. */\n @property({ type: Boolean }) ring = false;\n @property({ type: String }) ringColor: string = 'primary';\n @property({ type: String }) ringOffset: string = '1px';\n\n /** Accessiblity: override the generated aria-label for screen readers. */\n @property({ type: String }) badgeLabel: string | null = null;\n\n /** Accessibility: if true, hides the badge from assistive tech (purely decorative). */\n @property({ type: Boolean })\n badgeAriaHidden = false;\n\n /** Make badge focusable/clickable and emit `badge-click`. */\n @property({ type: Boolean }) interactive = false;\n\n /** Corner preset; use \"custom\" to rely on offsetX/offsetY and existing behavior. */\n @property({ type: String, reflect: true }) placement: SkyBadgePlacement =\n 'custom';\n\n @query('.badge') private _badgeEl!: HTMLSpanElement;\n\n /** Ref for the badge element (e.g. for tooltip anchor or positioning). */\n public badgeRef = createRef<HTMLSpanElement>();\n\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n };\n\n static override styles = css`\n :host {\n display: inline-block;\n position: relative;\n box-sizing: border-box;\n /* Theming: override with --sky-badge-* for custom sizing */\n --sky-badge-radius: var(--sky-radius-secondary);\n --sky-badge-padding: var(--sky-space-0\\\\.5, 0.125rem);\n --sky-badge-font-size: var(--sky-font-size-xs, 0.75rem);\n --sky-badge-font-weight: var(--sky-font-weight-bold, 700);\n --sky-badge-shadow: none;\n --sky-badge-translate-x: 0px;\n --sky-badge-translate-y: 0px;\n }\n\n .container {\n display: inline-flex;\n position: relative;\n align-items: center;\n }\n\n /* Badge base */\n .badge {\n min-height: 5px;\n padding: var(--sky-badge-padding);\n display: inline-flex;\n justify-content: center;\n align-items: center;\n box-shadow: var(--sky-badge-shadow);\n color: var(--_badge-text-color);\n background-color: var(--_badge-bg);\n border: var(--_badge-border, none);\n font: var(--sky-text-caption);\n font-weight: var(--sky-badge-font-weight);\n font-size: var(--sky-badge-font-size);\n line-height: var(--sky-line-height-none, 1);\n letter-spacing: var(--sky-letter-spacing-tight, -0.01em);\n position: absolute;\n z-index: 1;\n border-radius: var(--_badge-radius);\n min-width: var(--_badge-size);\n min-height: var(--_badge-size);\n top: var(--_anchor-top, auto);\n right: var(--_anchor-right, auto);\n bottom: var(--_anchor-bottom, auto);\n left: var(--_anchor-left, auto);\n transform: translate(\n var(--sky-badge-translate-x),\n var(--sky-badge-translate-y)\n );\n user-select: none;\n -webkit-user-select: none;\n white-space: nowrap;\n backdrop-filter: none;\n -webkit-backdrop-filter: none;\n transition: var(--sky-transition-fast);\n }\n\n @media (prefers-reduced-motion: reduce) {\n .badge {\n transition: none;\n }\n }\n\n /* Floating offsets & overlap */\n .badge.floating {\n transform: translate(\n calc(50% + var(--sky-badge-translate-x)),\n calc(-50% + var(--sky-badge-translate-y))\n );\n }\n\n /* Inline style participates in text flow */\n .badge.inline {\n position: static;\n display: inline-flex;\n margin-inline-start: var(--sky-space-1\\\\.5, 6px);\n transform: translate(\n var(--sky-badge-translate-x),\n var(--sky-badge-translate-y)\n );\n }\n\n /* Icon styling */\n sky-icon[part='icon'] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1em;\n height: 1em;\n font-size: var(--_icon-size);\n color: var(--_icon-color);\n backdrop-filter: none;\n -webkit-backdrop-filter: none;\n }\n\n /* Interactive affordances */\n .badge[role='button'] {\n cursor: pointer;\n outline: none;\n -webkit-tap-highlight-color: transparent;\n }\n .badge[role='button']:focus-visible {\n outline: none;\n box-shadow: var(--sky-focus-ring);\n }\n\n /* Ring (outline) */\n .badge.ringed::after {\n content: '';\n position: absolute;\n inset: calc(-1 * var(--_ring-offset));\n border-radius: inherit;\n box-shadow: 0 0 0 2px var(--_ring-color);\n pointer-events: none;\n }\n\n .badge[data-placement='top-center'] {\n transform: translate(\n calc(-50% + var(--sky-badge-translate-x)),\n var(--sky-badge-translate-y)\n );\n }\n\n /* Custom solid status fills (not soft semantic surfaces). */\n ${unsafeCSS(\n cssOnFillEnhance([\n {\n selector: '.badge[data-solid-contrast]',\n fillVar: '--_badge-bg',\n },\n {\n selector: '.badge[data-solid-contrast] sky-icon[part=\"icon\"]',\n fillVar: '--_badge-bg',\n },\n ])\n )}\n `;\n\n protected override updated(changed: PropertyValues<this>): void {\n if (changed.has('size')) {\n if (/^\\d+$/.test(this.size as string)) this.size = `${this.size}px`;\n }\n if (\n changed.has('position') &&\n !SKY_BADGE_POSITIONS.includes(this.position)\n ) {\n this.position = 'default';\n }\n if (changed.has('shape') && !SKY_BADGE_SHAPES.includes(this.shape)) {\n this.shape = 'custom';\n }\n if (\n changed.has('placement') &&\n !SKY_BADGE_PLACEMENTS.includes(this.placement)\n ) {\n this.placement = 'custom';\n }\n }\n\n /**\n * Forces badge visibility on.\n *\n * @returns {void}\n */\n public showBadge(): void {\n this.show = true;\n }\n\n /**\n * Forces badge visibility off.\n *\n * @returns {void}\n */\n public hideBadge(): void {\n this.show = false;\n }\n\n /**\n * Updates badge value for text/count or icon modes.\n *\n * @param value Badge value or icon name.\n * @returns {void}\n */\n public setValue(value: string): void {\n this.value = value;\n }\n\n /** Emits `badge-click` for interactive activation. */\n private _onActivate = (e: Event) => {\n if (!this.interactive) return;\n this.dispatchEvent(\n new CustomEvent<SkyBadgeClickEventDetail>('badge-click', {\n detail: { originalEvent: e },\n bubbles: true,\n composed: true,\n })\n );\n };\n\n /** Handles keyboard activation with Enter and Space. */\n private _onKeydown = (e: KeyboardEvent) => {\n if (!this.interactive) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n this._onActivate(e);\n }\n };\n\n /** Computes accessible badge label from current render state. */\n private _computeAriaLabel(displayValue: string | null): string | null {\n if (this.badgeAriaHidden) return null;\n if (this.badgeLabel) return this.badgeLabel;\n if (this.isIcon) return ''; // purely visual when icon unless overridden\n if (displayValue == null || displayValue === '') return 'Badge';\n const n = Number(displayValue);\n return isNaN(n) ? `Badge: ${displayValue}` : `Badge count: ${displayValue}`;\n }\n\n /** Resolves anchor edges from placement preset. */\n private _computeAnchors(placement: SkyBadgePlacement): {\n top: string;\n right: string;\n bottom: string;\n left: string;\n } {\n if (placement === 'custom') {\n return { top: '0', right: '0', bottom: 'auto', left: 'auto' };\n }\n switch (placement) {\n case 'top-right':\n return { top: '0', right: '0', bottom: 'auto', left: 'auto' };\n case 'top-left':\n return { top: '0', right: 'auto', bottom: 'auto', left: '0' };\n case 'bottom-left':\n return { top: 'auto', right: 'auto', bottom: '0', left: '0' };\n case 'bottom-right':\n return { top: 'auto', right: '0', bottom: '0', left: 'auto' };\n case 'top-center':\n return { top: '0', right: 'auto', bottom: 'auto', left: '50%' };\n default:\n return { top: '0', right: '0', bottom: 'auto', left: 'auto' };\n }\n }\n\n /** Maps semantic status tokens to soft badge surface colors. */\n private _resolveBadgeSurface(): {\n bg: string;\n color: string;\n border: string;\n } {\n const semanticKey = resolveSemanticSurfaceKey(this.statusColor);\n if (semanticKey) {\n const soft = semanticSoftSurfaceTokens(semanticKey, { bordered: true });\n const color =\n this.textColor && this.textColor !== 'default'\n ? resolveColor(this.textColor)\n : soft.color;\n return { bg: soft.bg, color, border: soft.border };\n }\n\n return {\n bg: resolveColor(this.statusColor),\n color:\n this.textColor && this.textColor !== 'default'\n ? resolveColor(this.textColor)\n : resolveTextColorForToken(this.statusColor),\n border: 'none',\n };\n }\n\n override render() {\n const numeric = Number(this.value);\n const isNumeric = !isNaN(numeric) && !this.isIcon;\n const shouldHideZero = this.hideWhenZero && isNumeric && numeric === 0;\n const visible = this.show && !shouldHideZero;\n const displayValue = this.isIcon\n ? null\n : isNumeric && this.max > 0 && numeric > this.max\n ? `${this.max}+`\n : this.value;\n\n const cls = ['badge', this.position];\n if (this.ring) cls.push('ringed');\n\n const computedRadius =\n this.shape === 'circle'\n ? 'var(--sky-radius-full)'\n : this.shape === 'pill'\n ? 'var(--sky-radius-full)'\n : 'var(--sky-badge-radius)';\n\n const surface = this._resolveBadgeSurface();\n const solidContrast =\n !resolveSemanticSurfaceKey(this.statusColor) &&\n (!this.textColor || this.textColor === 'default');\n const { top, right, bottom, left } = this._computeAnchors(this.placement);\n const badgeStyle = {\n '--_badge-bg': surface.bg,\n '--_badge-text-color': surface.color,\n '--_badge-border': surface.border,\n '--_badge-radius': computedRadius,\n '--_badge-size': this.size,\n '--_icon-size': this.size,\n '--_icon-color': resolveColor(this.iconColor || this.textColor),\n '--_ring-color': resolveColor(this.ringColor),\n '--_ring-offset': this.ringOffset,\n '--sky-badge-translate-x': this.offsetX,\n '--sky-badge-translate-y': this.offsetY,\n '--_anchor-top': top,\n '--_anchor-right': right,\n '--_anchor-bottom': bottom,\n '--_anchor-left': left,\n };\n\n const ariaLabel = this._computeAriaLabel(displayValue);\n\n return html`\n <div class=\"container\" part=\"container\">\n <slot></slot>\n ${when(\n visible,\n () => html`\n <span\n class=${cls.join(' ')}\n part=\"badge\"\n style=${styleMap(badgeStyle)}\n role=${this.interactive ? 'button' : 'status'}\n aria-live=${this.interactive ? 'off' : 'polite'}\n data-placement=${this.placement}\n ?data-solid-contrast=${solidContrast}\n aria-atomic=\"true\"\n aria-label=${ariaLabel ?? nothing}\n aria-hidden=${this.badgeAriaHidden ? 'true' : 'false'}\n tabindex=${this.interactive ? 0 : -1}\n @click=${this._onActivate}\n @keydown=${this._onKeydown}\n ${ref(this.badgeRef)}\n >\n <slot name=\"badge\">\n ${when(\n this.isIcon,\n () =>\n html`<sky-icon\n part=\"icon\"\n icon=${this.value}\n aria-hidden=\"true\"\n ></sky-icon>`,\n () => html`${displayValue}`\n )}\n </slot>\n </span>\n `\n )}\n </div>\n `;\n }\n}\n"],"names":["SKY_BADGE_POSITIONS","SKY_BADGE_SHAPES","SKY_BADGE_PLACEMENTS","SkyBadge","LitElement","constructor","super","arguments","this","statusColor","textColor","iconColor","position","value","isIcon","size","shape","max","hideWhenZero","show","offsetX","offsetY","ring","ringColor","ringOffset","badgeLabel","badgeAriaHidden","interactive","placement","badgeRef","createRef","_onActivate","e","dispatchEvent","CustomEvent","detail","originalEvent","bubbles","composed","_onKeydown","key","preventDefault","updated","changed","has","test","includes","showBadge","hideBadge","setValue","_computeAriaLabel","displayValue","n","Number","isNaN","_computeAnchors","top","right","bottom","left","_resolveBadgeSurface","semanticKey","resolveSemanticSurfaceKey","soft","semanticSoftSurfaceTokens","bordered","color","resolveColor","bg","border","resolveTextColorForToken","render","numeric","isNumeric","shouldHideZero","visible","cls","push","computedRadius","surface","solidContrast","badgeStyle","ariaLabel","html","when","join","styleMap","nothing","ref","dependencies","SkyIcon","shadowRootOptions","mode","delegatesFocus","styles","css","unsafeCSS","cssOnFillEnhance","selector","fillVar","__decorateClass","property","type","String","reflect","prototype","Boolean","query","customElement"],"mappings":"+wBAyBA,MAAMA,EAAmD,CACvD,UACA,WACA,UAEIC,EAA6C,CACjD,SACA,OACA,UAEIC,EAAqD,CACzD,SACA,YACA,WACA,cACA,eACA,cA6EK,IAAMC,EAAN,cAAuBC,EAAvB,WAAAC,GAAAC,SAAAC,WAOLC,KAAAC,YAAsB,UAItBD,KAAAE,UAAoB,UAIpBF,KAAAG,UAAoB,GAGuBH,KAAAI,SACzC,UAG0BJ,KAAAK,MAAgB,GAGAL,KAAAM,QAAS,EAGVN,KAAAO,KAAe,GAGfP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AEC,KAAMI,QAASF,SAAS,KAxCzBrG,EAwCiCsG,UAAA,OAAA,GAGhBL,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,UA3CPpG,EA2CiBsG,UAAA,UAAA,GACAL,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,UA5CPpG,EA4CiBsG,UAAA,UAAA,GAGCL,EAAA,CAA5BC,EAAS,CAAEC,KAAMI,WA/CPvG,EA+CkBsG,UAAA,OAAA,GACDL,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,UAhDPpG,EAgDiBsG,UAAA,YAAA,GACAL,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,UAjDPpG,EAiDiBsG,UAAA,aAAA,GAGAL,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,UApDPpG,EAoDiBsG,UAAA,aAAA,GAI5BL,EAAA,CADCC,EAAS,CAAEC,KAAMI,WAvDPvG,EAwDXsG,UAAA,kBAAA,GAG6BL,EAAA,CAA5BC,EAAS,CAAEC,KAAMI,WA3DPvG,EA2DkBsG,UAAA,cAAA,GAGcL,EAAA,CAA1CC,EAAS,CAAEC,KAAMC,OAAQC,SAAS,KA9DxBrG,EA8DgCsG,UAAA,YAAA,GAGlBL,EAAA,CAAxBO,EAAM,WAjEIxG,EAiEcsG,UAAA,WAAA,GAjEdtG,EAANiG,EAAA,CADNQ,EAAc,cACFzG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LitElement } from
|
|
2
|
-
export type SkyButtonVariant =
|
|
3
|
-
export type SkyButtonType =
|
|
4
|
-
export type SkyButtonAnimation =
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export type SkyButtonVariant = 'solid' | 'faded' | 'bordered' | 'transparent' | 'flat' | 'ghost' | 'relief' | 'gradient' | 'shadow' | 'link';
|
|
3
|
+
export type SkyButtonType = 'button' | 'submit' | 'reset';
|
|
4
|
+
export type SkyButtonAnimation = 'auto' | 'none' | 'lift' | 'push' | 'scale' | 'rotate' | 'custom';
|
|
5
5
|
/**
|
|
6
6
|
* @element sky-button
|
|
7
7
|
*
|
|
@@ -10,7 +10,7 @@ export type SkyButtonAnimation = "auto" | "none" | "lift" | "push" | "scale" | "
|
|
|
10
10
|
* @status stable
|
|
11
11
|
* @since 1.0.0
|
|
12
12
|
*
|
|
13
|
-
* @documentation https://
|
|
13
|
+
* @documentation https://sky-ui.com/components/button
|
|
14
14
|
* @dependency sky-icon
|
|
15
15
|
*
|
|
16
16
|
* @slot - Default slot for the button label (replaces `label` property if used).
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{unsafeCSS as o,css as t,LitElement as r,html as e,nothing as n}from"lit";import{property as a,state as i,eventOptions as s,customElement as l}from"lit/decorators.js";import{when as d}from"lit/directives/when.js";import{styleMap as h}from"lit/directives/style-map.js";import{resolveColor as p,resolveTextColorForToken as c,createGradient as b,tuneSurfaceVariantForDefaultColor as v,resolveSemanticSurfaceKey as g,semanticSoftSurfaceTokens as u,darkShade as f,fadeMix as y,skyBorderPrimaryShorthand as m,hoverShade as x}from"../helper/utils/color-resolver.js";import{cssOnFillEnhance as k}from"../helper/utils/contrast-color.js";import{resolveRadius as w}from"../helper/utils/size-resolver.js";import{ifDefined as S}from"lit/directives/if-defined.js";import{SkyIcon as $}from"../sky-icon/sky-icon.js";var B=Object.defineProperty,C=Object.getOwnPropertyDescriptor,_=(o,t,r,e)=>{for(var n,a=e>1?void 0:e?C(t,r):t,i=o.length-1;i>=0;i--)(n=o[i])&&(a=(e?n(t,r,a):n(a))||a);return e&&a&&B(t,r,a),a};let z=class extends r{constructor(){super(),this.variant="solid",this.color="primary",this.type="button",this.form="",this.size="md",this.radius="md",this.label="Button",this.disabled=!1,this.loading=!1,this.iconL="",this.iconR="",this.iconOnly=!1,this.colors="",this.animation="auto",this.inGroup=!1,this._hasMeaningfulSlot=!1,this._styleVars={},this._onSlotChange=o=>{const t=o.target,r=this._slotHasMeaningfulContent(t);r!==this._hasMeaningfulSlot&&(this._hasMeaningfulSlot=r)},this.internals=this.attachInternals()}_slotHasMeaningfulContent(o){return o.assignedNodes({flatten:!0}).some(o=>o.nodeType===Node.ELEMENT_NODE||(o.textContent??"").trim().length>0)}_toSquarePadding(o){const t=parseFloat(o.trim().split(/\s+/)[0]);return`${Number.isFinite(t)?t:8}px`}_resolveSize(o){const t={xs:{padding:"3px 7px",fontSize:"12px",gap:"3px",icon:"14px",spinner:"14px"},sm:{padding:"5px 9px",fontSize:"14px",gap:"4px",icon:"16px",spinner:"16px"},md:{padding:"8px 14px",fontSize:"16px",gap:"5px",icon:"18px",spinner:"18px"},lg:{padding:"10px 18px",fontSize:"18px",gap:"6px",icon:"20px",spinner:"20px"},xl:{padding:"14px 24px",fontSize:"20px",gap:"8px",icon:"24px",spinner:"24px"}};if(t[o])return t[o];const r=String(o).trim().match(/^([\d.]+)(px|rem|em)?$/i),e=r?.[2]||"px",n=r?parseFloat(r[1]):16,a=`${n}${e}`,i=o=>`${Math.round(100*o)/100}${e}`,s=(o,t,r)=>Math.max(t,Math.min(r,o)),l=s(.55*n,4,18),d=s(.9*n,8,28),h=s(.3*n,3,10),p=s(1.125*n,12,28),c=p;return{padding:`${i(l)} ${i(d)}`,fontSize:a,gap:i(h),icon:i(p),spinner:i(c)}}_isThemeBorderShorthand(o){return!(!o||"none"===o)&&/^var\(--sky-border-/.test(o.trim())}_borderColorFromShorthand(o){if(!o||"none"===o||this._isThemeBorderShorthand(o))return"transparent";const t=o.match(/solid\s+(.+)$/);return t?.[1]?.trim()??"transparent"}willUpdate(o){if(!["color","variant","size","radius","animation","inGroup","disabled","loading","colors","iconOnly"].some(t=>o.has(t))&&Object.keys(this._styleVars).length>0)return;const t=p(this.color),r=c(this.color),e={solid:{bg:t,color:r,border:"none",shadow:"none",hoverBg:t,hoverColor:r,hoverShadow:"var(--sky-box-shadow-hover)"},faded:{bg:"var(--sky-hover-tertiary)",color:t,border:"1px solid var(--sky-text-tertiary)",shadow:"none",hoverBg:"var(--sky-hover-secondary)",hoverColor:t,hoverShadow:"none",hoverBorder:"1px solid var(--sky-text-secondary)"},bordered:{bg:"transparent",color:t,border:`2px solid ${t}`,shadow:"none",hoverBg:"transparent",hoverColor:t,hoverShadow:"none",hoverBorder:`2px solid ${x(t,25)}`},transparent:{bg:"transparent",color:t,border:"none",shadow:"none",hoverBg:y(t,15),hoverColor:t,hoverShadow:"none"},flat:{bg:y(t,20),color:x(t,30),border:"none",shadow:"none",hoverBg:y(t,25),hoverColor:x(t,35),hoverShadow:"none"},ghost:{bg:"transparent",color:t,border:`2px solid ${t}`,shadow:"none",hoverBg:t,hoverColor:r,hoverShadow:"none"},shadow:{bg:"var(--sky-glass-primary)",color:"var(--sky-text-primary)",border:m(),shadow:"none",hoverBg:"var(--sky-glass-primary)",hoverColor:t,hoverShadow:"var(--sky-box-shadow-hover)",hoverBorder:m()},relief:{bg:t,color:r,border:"none",shadow:`\n inset 0 1px 0 rgba(255,255,255,0.4),\n 0 3px 0 ${f(t,40)},\n 0 4px 6px -1px ${y(t,40)}\n `,hoverBg:t,hoverColor:r,hoverShadow:"none"},gradient:{bg:b(this.colors,t),color:r,border:"none",shadow:"none",hoverBg:b(this.colors,t),hoverColor:r,hoverShadow:"none"},link:{bg:"transparent",color:t,border:"none",shadow:"none",hoverBg:"transparent",hoverColor:t,hoverShadow:"none"}},n=this.variant in e?this.variant:"solid";let a={...e[n]};Object.assign(a,v(this.color,n,e[n]));const i=g(this.color);if(i&&("flat"===n||"faded"===n)){const o=u(i,{bordered:"faded"===n});Object.assign(a,{bg:o.bg,color:o.color,border:"faded"===n?o.border:"none",hoverBg:"var(--sky-hover-primary)",hoverColor:o.color,hoverShadow:"none",..."faded"===n?{hoverBorder:o.border}:{}})}const s=this.inGroup?"none":this.animation,l="auto"===s?{solid:{hover:"translateY(-3px)",active:"translateY(-3px)"},faded:{},bordered:{},transparent:{},flat:{},ghost:{},shadow:{hover:"translateY(-3px)",active:"translateY(-3px)"},gradient:{},relief:{hover:"translateY(2px)",active:"translateY(2px)"},link:{}}[n]:(o=>{switch(o){case"none":return{hover:"none",active:"none"};case"lift":return{hover:"translateY(-2px)",active:"translateY(-1px)"};case"push":return{hover:"translateY(2px)",active:"translateY(2px)"};case"scale":return{hover:"scale(1.05)",active:"scale(1.02)"};case"rotate":return{hover:"rotate(3deg)",active:"rotate(2deg)"};case"custom":return{hover:"var(--btn-hover-transform, none)",active:"var(--btn-active-transform, var(--btn-hover-transform, none))"};default:return{}}})(s),d=l.hover??"none",h=l.active??d??"none",k=this._resolveSize(this.size),S=this.iconOnly?this._toSquarePadding(k.padding):k.padding,$=this.iconOnly?"0":k.gap;let B=0;const C="bordered"===this.variant||"ghost"===this.variant,_="faded"===this.variant||"shadow"===this.variant;if(C)B=2;else if(_)B=1;else if(a.border&&a.border.includes("px")){const o=a.border.match(/(\d+)px/);B=o?parseInt(o[1]):0}let z=B;if(a.hoverBorder&&a.hoverBorder.includes("px")){const o=a.hoverBorder.match(/(\d+)px/);z=o?parseInt(o[1]):B}let O="link"===this.variant?"0":S;if(B>0){const o=S.split(" ");if(1===o.length){const t=parseFloat(o[0]);O=`${Math.max(t-B,2)}px`}else if(2===o.length){const t=parseFloat(o[0]),r=parseFloat(o[1]),e=Math.max(t-B,2);O=this.iconOnly?`${e}px`:`${e}px ${r}px`}else if(4===o.length){const t=parseFloat(o[0]),r=parseFloat(o[1]),e=parseFloat(o[2]),n=parseFloat(o[3]);O=`${Math.max(t-B,2)}px ${r}px ${Math.max(e-B,2)}px ${n}px`}}const F=parseFloat(k.fontSize),M=parseFloat(k.icon);let j,Y;if("link"===this.variant)j="auto";else if(this.iconOnly){const o=2*(parseFloat(O)||0)+M+2*B;j=`${o}px`,Y=`${o}px`}else{const o=O.split(" ");j=`${(o.length>=2?parseFloat(o[0])+parseFloat(o[2]||o[0]):2*parseFloat(o[0])||16)+F+4+2*B}px`}const R=a.hoverBorder,E=this._isThemeBorderShorthand(a.border)||this._isThemeBorderShorthand(R),N=this._borderColorFromShorthand(a.border),L=this._borderColorFromShorthand(R??a.border),T={"--btn-color":a.color,"--btn-shadow":a.shadow,"--btn-radius":"link"===this.variant?"0":w(this.radius),"--btn-color-hover":a.hoverColor,"--btn-shadow-hover":a.hoverShadow,"--btn-transform":"none","--btn-transform-hover":d,"--btn-transform-active":h,"--btn-padding":O,"--btn-font-size":k.fontSize,"--btn-gap":$,"--icon-size":k.icon,"--spinner-size":k.spinner,"--btn-min-height":j,...Y?{"--btn-min-width":Y}:{},"--btn-border-width":`${B}px`,"--btn-border-width-hover":`${z}px`};E?(T["--btn-border"]=a.border,T["--btn-border-hover"]=R??a.border):(T["--btn-border-color"]=N,T["--btn-border-color-hover"]=L),"gradient"===this.variant?(T["--btn-bg"]=a.bg,T["--btn-bg-hover"]=a.hoverBg,T["--btn-bg-color"]=t,T["--btn-bg-color-hover"]=t):(T["--btn-bg-color"]=a.bg,T["--btn-bg-color-hover"]=a.hoverBg),this.inGroup&&("gradient"===this.variant?(T["--btn-bg"]="transparent",T["--btn-bg-hover"]="color-mix(in srgb, white 8%, transparent)"):T["--btn-bg-color-hover"]=T["--btn-bg-color"]??"transparent",T["--btn-color-hover"]=T["--btn-color"],E?T["--btn-border-hover"]=T["--btn-border"]??a.border:T["--btn-border-color-hover"]=T["--btn-border-color"]??N,T["--btn-shadow-hover"]="none","relief"===this.variant?(T["--btn-transform-hover"]="translateY(2px)",T["--btn-transform-active"]="translateY(2px)"):(T["--btn-transform-hover"]="none",T["--btn-transform-active"]="none")),this._styleVars=T}focusButton(){this.renderRoot.querySelector("button")?.focus()}clickButton(){this.disabled||this.loading||this.renderRoot.querySelector("button")?.click()}_createRipple(o){const t=o.currentTarget,r=t.getBoundingClientRect(),e=document.createElement("span"),n=Math.max(t.offsetWidth,t.offsetHeight),a=o.clientX-r.left-n/2,i=o.clientY-r.top-n/2;e.style.width=e.style.height=`${n}px`,e.style.left=`${a}px`,e.style.top=`${i}px`;const s=getComputedStyle(t).backgroundColor||"",l=s.includes("255, 255, 255")||s.includes("rgba(0, 0, 0, 0)");e.style.background=l?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.3)",e.className="ripple";const d=t.querySelectorAll(".ripple");d.length>=3&&d[0]&&d[0].remove(),t.appendChild(e),e.addEventListener("animationend",()=>e.remove())}formDisabledCallback(o){this.disabled=o}get formOwner(){if("undefined"==typeof document)return null;const o="string"==typeof this.form?this.form.trim():"";return this.internals.form||(o?document.getElementById(o):null)||this.closest("form")}_handleClick(o){if(this.disabled||this.loading)return void o.preventDefault();"button"===this.type&&o.preventDefault(),this._createRipple(o);const t=this.formOwner;"submit"!==this.type?"reset"!==this.type||t?.reset():t?.requestSubmit()}_iconOnlyName(){return this.iconL||this.iconR}render(){const o=this._iconOnlyName(),t=this.iconOnly&&(this.label||o)?this.label||o:void 0;return e`
|
|
2
2
|
<button
|
|
3
3
|
part="button"
|
|
4
|
-
style=${
|
|
4
|
+
style=${h(this._styleVars)}
|
|
5
5
|
type=${this.type}
|
|
6
|
-
form=${
|
|
7
|
-
aria-label=${
|
|
6
|
+
form=${S(this.form??void 0)}
|
|
7
|
+
aria-label=${S(t)}
|
|
8
8
|
?disabled=${this.disabled||this.loading}
|
|
9
9
|
?loading=${this.loading}
|
|
10
10
|
@click=${this._handleClick}
|
|
11
11
|
>
|
|
12
|
-
${
|
|
13
|
-
${
|
|
12
|
+
${d(this.iconOnly,()=>d(o,()=>e`<sky-icon part="icon" icon="${o}"></sky-icon>`),()=>e`
|
|
13
|
+
${d(this.iconL,()=>e`<sky-icon part="icon" icon="${this.iconL}"></sky-icon>`)}
|
|
14
14
|
<slot @slotchange=${this._onSlotChange}></slot>
|
|
15
|
-
${this._hasMeaningfulSlot?
|
|
16
|
-
${
|
|
15
|
+
${this._hasMeaningfulSlot?n:this.label}
|
|
16
|
+
${d(this.iconR,()=>e`<sky-icon part="icon" icon="${this.iconR}"></sky-icon>`)}
|
|
17
17
|
`)}
|
|
18
|
-
${
|
|
18
|
+
${d(this.loading,()=>e`
|
|
19
19
|
<div class="loading-overlay" part="loading-overlay">
|
|
20
20
|
<div class="spinner" part="spinner"></div>
|
|
21
21
|
</div>
|
|
22
22
|
`)}
|
|
23
23
|
</button>
|
|
24
|
-
`}};
|
|
24
|
+
`}};z.dependencies={"sky-icon":$},z.formAssociated=!0,z.styles=t`
|
|
25
25
|
:host {
|
|
26
26
|
display: inline-block;
|
|
27
27
|
}
|
|
@@ -42,7 +42,7 @@ import{css as o,LitElement as r,html as t,nothing as e}from"lit";import{property
|
|
|
42
42
|
gap: 0;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
:host([variant=
|
|
45
|
+
:host([variant='link']) button {
|
|
46
46
|
width: auto;
|
|
47
47
|
border-radius: 0;
|
|
48
48
|
text-decoration: none;
|
|
@@ -52,14 +52,16 @@ import{css as o,LitElement as r,html as t,nothing as e}from"lit";import{property
|
|
|
52
52
|
background-repeat: no-repeat;
|
|
53
53
|
background-size: 0% 1px;
|
|
54
54
|
transition:
|
|
55
|
-
background-size var(--sky-duration-normal, 200ms)
|
|
55
|
+
background-size var(--sky-duration-normal, 200ms)
|
|
56
|
+
var(--sky-ease-default, ease),
|
|
56
57
|
color var(--sky-duration-fast, 120ms) var(--sky-ease-default, ease),
|
|
57
58
|
box-shadow var(--sky-duration-fast, 120ms) var(--sky-ease-default, ease),
|
|
58
|
-
border-color var(--sky-duration-fast, 120ms)
|
|
59
|
+
border-color var(--sky-duration-fast, 120ms)
|
|
60
|
+
var(--sky-ease-default, ease),
|
|
59
61
|
transform var(--sky-duration-fast, 120ms) var(--sky-ease-default, ease);
|
|
60
62
|
}
|
|
61
|
-
:host([variant=
|
|
62
|
-
:host([variant=
|
|
63
|
+
:host([variant='link']) button:hover:not(:disabled),
|
|
64
|
+
:host([variant='link']) button:focus-visible:not(:disabled) {
|
|
63
65
|
background-color: transparent;
|
|
64
66
|
background-image: linear-gradient(currentColor, currentColor);
|
|
65
67
|
background-position: 0 100%;
|
|
@@ -88,7 +90,10 @@ import{css as o,LitElement as r,html as t,nothing as e}from"lit";import{property
|
|
|
88
90
|
box-shadow: var(--btn-shadow, none);
|
|
89
91
|
transform: var(--btn-transform, none);
|
|
90
92
|
gap: var(--btn-gap, var(--sky-space-1, 4px));
|
|
91
|
-
padding: var(
|
|
93
|
+
padding: var(
|
|
94
|
+
--btn-padding,
|
|
95
|
+
var(--sky-space-2, 8px) var(--sky-space-3, 14px)
|
|
96
|
+
);
|
|
92
97
|
font-size: var(--btn-font-size, var(--sky-font-size-md, 1rem));
|
|
93
98
|
font-family: var(--sky-font);
|
|
94
99
|
white-space: nowrap;
|
|
@@ -100,8 +105,10 @@ import{css as o,LitElement as r,html as t,nothing as e}from"lit";import{property
|
|
|
100
105
|
backdrop-filter: none;
|
|
101
106
|
-webkit-backdrop-filter: none;
|
|
102
107
|
transition:
|
|
103
|
-
background-color var(--sky-duration-fast, 120ms)
|
|
104
|
-
|
|
108
|
+
background-color var(--sky-duration-fast, 120ms)
|
|
109
|
+
var(--sky-ease-default, ease),
|
|
110
|
+
border-color var(--sky-duration-fast, 120ms)
|
|
111
|
+
var(--sky-ease-default, ease),
|
|
105
112
|
color var(--sky-duration-fast, 120ms) var(--sky-ease-default, ease),
|
|
106
113
|
box-shadow var(--sky-duration-fast, 120ms) var(--sky-ease-default, ease),
|
|
107
114
|
transform var(--sky-duration-fast, 120ms) var(--sky-ease-out, ease),
|
|
@@ -111,14 +118,17 @@ import{css as o,LitElement as r,html as t,nothing as e}from"lit";import{property
|
|
|
111
118
|
flex-shrink: 0;
|
|
112
119
|
}
|
|
113
120
|
|
|
114
|
-
:host([variant=
|
|
121
|
+
:host([variant='gradient']) button {
|
|
115
122
|
background: var(--btn-bg);
|
|
116
123
|
background-color: transparent;
|
|
117
124
|
}
|
|
118
125
|
|
|
119
126
|
button:hover:not(:disabled),
|
|
120
127
|
button:focus-visible:not(:disabled) {
|
|
121
|
-
background-color: var(
|
|
128
|
+
background-color: var(
|
|
129
|
+
--btn-bg-color-hover,
|
|
130
|
+
var(--btn-bg-color, transparent)
|
|
131
|
+
);
|
|
122
132
|
color: var(--btn-color-hover, var(--btn-color));
|
|
123
133
|
box-shadow: var(--btn-shadow-hover, var(--btn-shadow));
|
|
124
134
|
border: var(
|
|
@@ -138,14 +148,13 @@ import{css as o,LitElement as r,html as t,nothing as e}from"lit";import{property
|
|
|
138
148
|
min-height: var(--btn-min-height, auto);
|
|
139
149
|
}
|
|
140
150
|
|
|
141
|
-
:host([variant=
|
|
142
|
-
:host([variant=
|
|
151
|
+
:host([variant='gradient']) button:hover:not(:disabled),
|
|
152
|
+
:host([variant='gradient']) button:focus-visible:not(:disabled) {
|
|
143
153
|
background: var(--btn-bg-hover, var(--btn-bg));
|
|
144
154
|
}
|
|
145
155
|
button:focus-visible:not(:disabled) {
|
|
146
156
|
box-shadow:
|
|
147
|
-
var(--sky-focus-ring),
|
|
148
|
-
var(--btn-shadow-hover, var(--btn-shadow, none));
|
|
157
|
+
var(--sky-focus-ring), var(--btn-shadow-hover, var(--btn-shadow, none));
|
|
149
158
|
}
|
|
150
159
|
button:active:not(:disabled) {
|
|
151
160
|
transform: var(
|
|
@@ -161,7 +170,7 @@ import{css as o,LitElement as r,html as t,nothing as e}from"lit";import{property
|
|
|
161
170
|
|
|
162
171
|
@media (prefers-reduced-motion: reduce) {
|
|
163
172
|
button,
|
|
164
|
-
:host([variant=
|
|
173
|
+
:host([variant='link']) button {
|
|
165
174
|
transition: none;
|
|
166
175
|
}
|
|
167
176
|
|
|
@@ -227,5 +236,8 @@ import{css as o,LitElement as r,html as t,nothing as e}from"lit";import{property
|
|
|
227
236
|
transform: rotate(360deg);
|
|
228
237
|
}
|
|
229
238
|
}
|
|
230
|
-
|
|
239
|
+
|
|
240
|
+
/* Solid fills: enhance FG with contrast-color when supported (fallback remains --btn-color). */
|
|
241
|
+
${o(k([{selector:':host(:is([variant="solid"], [variant="shadow"], [variant="relief"], [variant="gradient"]):not([data-text-explicit])) button',fillVar:"--btn-bg-color"},{selector:':host(:is([variant="solid"], [variant="shadow"], [variant="relief"], [variant="gradient"]):not([data-text-explicit])) button:hover:not(:disabled), :host(:is([variant="solid"], [variant="shadow"], [variant="relief"], [variant="gradient"]):not([data-text-explicit])) button:focus-visible:not(:disabled)',fillVar:"var(--btn-bg-color-hover, var(--btn-bg-color))"}]))}
|
|
242
|
+
`,_([a({type:String,reflect:!0})],z.prototype,"variant",2),_([a({type:String})],z.prototype,"color",2),_([a({type:String})],z.prototype,"type",2),_([a({type:String})],z.prototype,"form",2),_([a({type:String})],z.prototype,"size",2),_([a({type:String})],z.prototype,"radius",2),_([a({type:String})],z.prototype,"label",2),_([a({type:Boolean,reflect:!0})],z.prototype,"disabled",2),_([a({type:Boolean,reflect:!0})],z.prototype,"loading",2),_([a({type:String})],z.prototype,"iconL",2),_([a({type:String})],z.prototype,"iconR",2),_([a({type:Boolean,reflect:!0})],z.prototype,"iconOnly",2),_([a({type:String})],z.prototype,"colors",2),_([a({type:String,reflect:!0})],z.prototype,"animation",2),_([a({type:Boolean,reflect:!0})],z.prototype,"inGroup",2),_([i()],z.prototype,"_hasMeaningfulSlot",2),_([s({passive:!1})],z.prototype,"_handleClick",1),z=_([l("sky-button")],z);export{z as SkyButton};
|
|
231
243
|
//# sourceMappingURL=sky-button.js.map
|