@justeattakeaway/pie-button 0.36.1 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -1
- package/dist/index.js +152 -137
- package/dist/react.d.ts +7 -1
- package/dist/react.js +11 -10
- package/package.json +4 -5
- package/src/button.scss +4 -73
- package/src/index.ts +20 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CSSResult } from 'lit';
|
|
2
2
|
import type { LitElement } from 'lit';
|
|
3
3
|
import type { PropertyValues } from 'lit';
|
|
4
|
-
import type { TemplateResult } from 'lit
|
|
4
|
+
import type { TemplateResult } from 'lit';
|
|
5
5
|
|
|
6
6
|
export declare interface ButtonProps {
|
|
7
7
|
/**
|
|
@@ -118,6 +118,12 @@ export declare class PieButton extends LitElement implements ButtonProps {
|
|
|
118
118
|
private _simulateNativeButtonClick;
|
|
119
119
|
private _handleClick;
|
|
120
120
|
private _handleFormKeyDown;
|
|
121
|
+
/**
|
|
122
|
+
* Template for the loading state
|
|
123
|
+
*
|
|
124
|
+
* @private
|
|
125
|
+
*/
|
|
126
|
+
private renderSpinner;
|
|
121
127
|
render(): TemplateResult<1>;
|
|
122
128
|
focus(): void;
|
|
123
129
|
static styles: CSSResult;
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { unsafeCSS as wt, LitElement as Et, html as
|
|
2
|
-
import { property as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { unsafeCSS as wt, LitElement as Et, html as N, nothing as R } from "lit";
|
|
2
|
+
import { property as b } from "lit/decorators.js";
|
|
3
|
+
import "@justeattakeaway/pie-spinner";
|
|
4
|
+
const P = (d, n, a) => function(p, y) {
|
|
5
|
+
const m = `#${y}`;
|
|
6
|
+
Object.defineProperty(p, y, {
|
|
6
7
|
get() {
|
|
7
|
-
return this[
|
|
8
|
+
return this[m];
|
|
8
9
|
},
|
|
9
|
-
set(
|
|
10
|
-
const L = this[
|
|
11
|
-
n.includes(
|
|
12
|
-
`<${d}> Invalid value "${
|
|
10
|
+
set(u) {
|
|
11
|
+
const L = this[m];
|
|
12
|
+
n.includes(u) ? this[m] = u : (console.error(
|
|
13
|
+
`<${d}> Invalid value "${u}" provided for property "${y}".`,
|
|
13
14
|
`Must be one of: ${n.join(" | ")}.`,
|
|
14
15
|
`Falling back to default value: "${a}"`
|
|
15
|
-
), this[
|
|
16
|
+
), this[m] = a), this.requestUpdate(y, L);
|
|
16
17
|
}
|
|
17
18
|
});
|
|
18
19
|
};
|
|
@@ -29,10 +30,10 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
29
30
|
"ghost-inverse",
|
|
30
31
|
"destructive",
|
|
31
32
|
"destructive-ghost"
|
|
32
|
-
], Lt = ["leading", "trailing"], St = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], Vt = ["post", "get", "dialog"], Nt = ["_self", "_blank", "_parent", "_top"], Ft = `*,*:before,*:after{box-sizing:border-box}@keyframes rotate360{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.o-btn{--btn-border-radius: var(--dt-radius-rounded-e);--btn-font-family: var(--dt-font-interactive-m-family);--btn-font-weight: var(--dt-font-interactive-m-weight);--btn-padding: 10px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--btn-bg-color: var(--dt-color-interactive-brand);--btn-text-color: var(--dt-color-content-interactive-primary);--btn-height--xsmall: 32px;--btn-height--small: 40px;--btn-height--medium: 48px;--btn-height--large: 56px;--btn-height: var(--btn-height--medium);--btn-icon-size: 24px;--spinner-size-s: 20px;--spinner-size-m: 24px;--spinner-border-width-s: 2.5px;--spinner-border-width-m: 3px;--spinner-size: var(--spinner-size-m);--spinner-border-width: var(--spinner-border-width-m);--spinner-base-color-h: var(--dt-color-content-interactive-primary-h);--spinner-base-color-s: var(--dt-color-content-interactive-primary-s);--spinner-base-color-l: var(--dt-color-content-interactive-primary-l);--spinner-left-color-opacity: .35;--spinner-left-color: hsl(var(--spinner-base-color-h), var(--spinner-base-color-s), var(--spinner-base-color-l), var(--spinner-left-color-opacity));--spinner-right-color: hsl(var(--spinner-base-color-h), var(--spinner-base-color-s), var(--spinner-base-color-l), 1);--spinner-animation-duration: 1.15s;--spinner-animation-timing-function: linear;--spinner-animation-iteration-count: infinite;position:relative;display:flex;gap:var(--dt-spacing-b);align-items:center;justify-content:center;box-sizing:border-box;height:var(--btn-height);padding:var(--btn-padding);border:none;border-radius:var(--btn-border-radius);outline:none;background-color:var(--btn-bg-color);font-family:var(--btn-font-family);font-size:var(--btn-font-size);font-weight:var(--btn-font-weight);color:var(--btn-text-color);line-height:var(--btn-line-height);cursor:pointer;user-select:none;inline-size:var(--btn-inline-size)}.o-btn[variant=primary]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--hover-modifier)))}.o-btn[variant=primary]:active:not(:disabled),.o-btn[variant=primary][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--active-modifier)))}.o-btn[variant=primary][size=xsmall],.o-btn[variant=primary][size=small-productive]{--btn-bg-color: var(--dt-color-interactive-primary)}.o-btn[variant=primary][size=xsmall]:hover:not(:disabled),.o-btn[variant=primary][size=small-productive]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-02));--btn-bg-color: hsl(var(--dt-color-interactive-primary-h), var(--dt-color-interactive-primary-s), calc(var(--dt-color-interactive-primary-l) + var(--hover-modifier)))}.o-btn[variant=primary][size=xsmall]:active:not(:disabled),.o-btn[variant=primary][size=xsmall][isLoading]:not(:disabled),.o-btn[variant=primary][size=small-productive]:active:not(:disabled),.o-btn[variant=primary][size=small-productive][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-02));--btn-bg-color: hsl(var(--dt-color-interactive-primary-h), var(--dt-color-interactive-primary-s), calc(var(--dt-color-interactive-primary-l) + var(--active-modifier)))}.o-btn[variant=secondary]{--btn-bg-color: var(--dt-color-interactive-secondary);--btn-text-color: var(--dt-color-content-interactive-secondary);--spinner-base-color-h: var(--dt-color-content-interactive-secondary-h);--spinner-base-color-s: var(--dt-color-content-interactive-secondary-s);--spinner-base-color-l: var(--dt-color-content-interactive-secondary-l)}.o-btn[variant=secondary]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-secondary-h), var(--dt-color-interactive-secondary-s), calc(var(--dt-color-interactive-secondary-l) + var(--hover-modifier)))}.o-btn[variant=secondary]:active:not(:disabled),.o-btn[variant=secondary][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-secondary-h), var(--dt-color-interactive-secondary-s), calc(var(--dt-color-interactive-secondary-l) + var(--active-modifier)))}.o-btn[variant=outline]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-secondary);border:1px solid var(--dt-color-border-strong);--spinner-base-color-h: var(--dt-color-content-interactive-secondary-h);--spinner-base-color-s: var(--dt-color-content-interactive-secondary-s);--spinner-base-color-l: var(--dt-color-content-interactive-secondary-l)}.o-btn[variant=outline]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=outline]:active:not(:disabled),.o-btn[variant=outline][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[variant=ghost]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-link);--spinner-base-color-h: var(--dt-color-content-interactive-secondary-h);--spinner-base-color-s: var(--dt-color-content-interactive-secondary-s);--spinner-base-color-l: var(--dt-color-content-interactive-secondary-l)}.o-btn[variant=ghost]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=ghost]:active:not(:disabled),.o-btn[variant=ghost][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[variant=inverse]{--btn-bg-color: var(--dt-color-interactive-inverse);--btn-text-color: var(--dt-color-content-interactive-secondary);--spinner-base-color-h: var(--dt-color-content-interactive-secondary-h);--spinner-base-color-s: var(--dt-color-content-interactive-secondary-s);--spinner-base-color-l: var(--dt-color-content-interactive-secondary-l)}.o-btn[variant=inverse]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-inverse-h), var(--dt-color-interactive-inverse-s), calc(var(--dt-color-interactive-inverse-l) + var(--hover-modifier)))}.o-btn[variant=inverse]:active:not(:disabled),.o-btn[variant=inverse][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-inverse-h), var(--dt-color-interactive-inverse-s), calc(var(--dt-color-interactive-inverse-l) + var(--active-modifier)))}.o-btn[variant=ghost-inverse],.o-btn[variant=outline-inverse]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-primary)}.o-btn[variant=ghost-inverse]:hover:not(:disabled),.o-btn[variant=outline-inverse]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), var(--dt-color-container-default-l), var(--hover-modifier))}.o-btn[variant=ghost-inverse]:active:not(:disabled),.o-btn[variant=ghost-inverse][isLoading]:not(:disabled),.o-btn[variant=outline-inverse]:active:not(:disabled),.o-btn[variant=outline-inverse][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), var(--dt-color-container-default-l), var(--active-modifier))}.o-btn[variant=outline-inverse]{border:1px solid var(--dt-color-border-strong)}.o-btn[variant=destructive]{--btn-bg-color: var(--dt-color-support-error)}.o-btn[variant=destructive]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + var(--hover-modifier)))}.o-btn[variant=destructive]:active:not(:disabled),.o-btn[variant=destructive][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + var(--active-modifier)))}.o-btn[variant=destructive-ghost]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-error);--spinner-base-color-h: var(--dt-color-content-interactive-secondary-h);--spinner-base-color-s: var(--dt-color-content-interactive-secondary-s);--spinner-base-color-l: var(--dt-color-content-interactive-secondary-l)}.o-btn[variant=destructive-ghost]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=destructive-ghost]:active:not(:disabled),.o-btn[variant=destructive-ghost][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[isFullWidth]{--btn-inline-size: 100%}.o-btn[disabled]{--btn-text-color: var(--dt-color-content-disabled) !important;cursor:not-allowed}.o-btn[disabled]:not([variant=ghost],[variant=ghost-inverse],[variant=destructive-ghost]){--btn-bg-color: var(--dt-color-disabled-01) !important}.o-btn[disabled][variant=outline]{border-color:var(--dt-color-disabled-01)!important}.o-btn[size=xsmall]{--btn-height: var(--btn-height--xsmall);--btn-padding: 6px var(--dt-spacing-b);--btn-font-size: calc(var(--dt-font-size-14) * 1px);--btn-line-height: calc(var(--dt-font-size-14-line-height) * 1px);--btn-icon-size: 16px;--spinner-size: var(--spinner-size-s);--spinner-border-width: var(--spinner-border-width-s)}.o-btn[size=small-expressive],.o-btn[size=small-productive]{--btn-height: var(--btn-height--small);--btn-icon-size: 20px;--spinner-size: var(--spinner-size-s);--spinner-border-width: var(--spinner-border-width-s)}.o-btn[size=small-expressive]{--btn-padding: 6px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px)}.o-btn[size=small-productive]{--btn-padding: 8px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-16) * 1px);--btn-line-height: calc(var(--dt-font-size-16-line-height) * 1px)}.o-btn[size=large]{--btn-height: var(--btn-height--large);--btn-padding: 14px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--spinner-size: var(--spinner-size-m);--spinner-border-width: var(--spinner-border-width-m)}.o-btn[isLoading]:before{content:"";position:absolute;left:50%;top:50%;translate:-50% -50%;height:var(--spinner-size);width:var(--spinner-size);display:block;background-color:transparent;border-radius:50%;border-color:var(--spinner-left-color) var(--spinner-right-color) var(--spinner-right-color) var(--spinner-left-color);border-width:var(--spinner-border-width);border-style:solid;will-change:transform;animation:rotate360 var(--spinner-animation-duration) var(--spinner-animation-timing-function) var(--spinner-animation-iteration-count)}.o-btn[isLoading]>*{visibility:hidden}.o-btn:focus-visible{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}::slotted(svg){height:var(--btn-icon-size);width:var(--btn-icon-size)}
|
|
33
|
+
], Lt = ["leading", "trailing"], Vt = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], Nt = ["post", "get", "dialog"], Pt = ["_self", "_blank", "_parent", "_top"], Ft = `*,*:before,*:after{box-sizing:border-box}.o-btn{--btn-border-radius: var(--dt-radius-rounded-e);--btn-font-family: var(--dt-font-interactive-m-family);--btn-font-weight: var(--dt-font-interactive-m-weight);--btn-padding: 10px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--btn-bg-color: var(--dt-color-interactive-brand);--btn-text-color: var(--dt-color-content-interactive-primary);--btn-height--xsmall: 32px;--btn-height--small: 40px;--btn-height--medium: 48px;--btn-height--large: 56px;--btn-height: var(--btn-height--medium);--btn-icon-size: 24px;position:relative;display:flex;gap:var(--dt-spacing-b);align-items:center;justify-content:center;box-sizing:border-box;height:var(--btn-height);padding:var(--btn-padding);border:none;border-radius:var(--btn-border-radius);outline:none;background-color:var(--btn-bg-color);font-family:var(--btn-font-family);font-size:var(--btn-font-size);font-weight:var(--btn-font-weight);color:var(--btn-text-color);line-height:var(--btn-line-height);cursor:pointer;user-select:none;inline-size:var(--btn-inline-size)}.o-btn[variant=primary]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--hover-modifier)))}.o-btn[variant=primary]:active:not(:disabled),.o-btn[variant=primary][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--active-modifier)))}.o-btn[variant=primary][size=xsmall],.o-btn[variant=primary][size=small-productive]{--btn-bg-color: var(--dt-color-interactive-primary)}.o-btn[variant=primary][size=xsmall]:hover:not(:disabled),.o-btn[variant=primary][size=small-productive]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-02));--btn-bg-color: hsl(var(--dt-color-interactive-primary-h), var(--dt-color-interactive-primary-s), calc(var(--dt-color-interactive-primary-l) + var(--hover-modifier)))}.o-btn[variant=primary][size=xsmall]:active:not(:disabled),.o-btn[variant=primary][size=xsmall][isLoading]:not(:disabled),.o-btn[variant=primary][size=small-productive]:active:not(:disabled),.o-btn[variant=primary][size=small-productive][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-02));--btn-bg-color: hsl(var(--dt-color-interactive-primary-h), var(--dt-color-interactive-primary-s), calc(var(--dt-color-interactive-primary-l) + var(--active-modifier)))}.o-btn[variant=secondary]{--btn-bg-color: var(--dt-color-interactive-secondary);--btn-text-color: var(--dt-color-content-interactive-secondary)}.o-btn[variant=secondary]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-secondary-h), var(--dt-color-interactive-secondary-s), calc(var(--dt-color-interactive-secondary-l) + var(--hover-modifier)))}.o-btn[variant=secondary]:active:not(:disabled),.o-btn[variant=secondary][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-secondary-h), var(--dt-color-interactive-secondary-s), calc(var(--dt-color-interactive-secondary-l) + var(--active-modifier)))}.o-btn[variant=outline]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-secondary);border:1px solid var(--dt-color-border-strong)}.o-btn[variant=outline]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=outline]:active:not(:disabled),.o-btn[variant=outline][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[variant=ghost]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-link)}.o-btn[variant=ghost]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=ghost]:active:not(:disabled),.o-btn[variant=ghost][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[variant=inverse]{--btn-bg-color: var(--dt-color-interactive-inverse);--btn-text-color: var(--dt-color-content-interactive-secondary)}.o-btn[variant=inverse]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-inverse-h), var(--dt-color-interactive-inverse-s), calc(var(--dt-color-interactive-inverse-l) + var(--hover-modifier)))}.o-btn[variant=inverse]:active:not(:disabled),.o-btn[variant=inverse][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-inverse-h), var(--dt-color-interactive-inverse-s), calc(var(--dt-color-interactive-inverse-l) + var(--active-modifier)))}.o-btn[variant=ghost-inverse],.o-btn[variant=outline-inverse]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-primary)}.o-btn[variant=ghost-inverse]:hover:not(:disabled),.o-btn[variant=outline-inverse]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), var(--dt-color-container-default-l), var(--hover-modifier))}.o-btn[variant=ghost-inverse]:active:not(:disabled),.o-btn[variant=ghost-inverse][isLoading]:not(:disabled),.o-btn[variant=outline-inverse]:active:not(:disabled),.o-btn[variant=outline-inverse][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), var(--dt-color-container-default-l), var(--active-modifier))}.o-btn[variant=outline-inverse]{border:1px solid var(--dt-color-border-strong)}.o-btn[variant=destructive]{--btn-bg-color: var(--dt-color-support-error)}.o-btn[variant=destructive]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + var(--hover-modifier)))}.o-btn[variant=destructive]:active:not(:disabled),.o-btn[variant=destructive][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + var(--active-modifier)))}.o-btn[variant=destructive-ghost]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-error)}.o-btn[variant=destructive-ghost]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=destructive-ghost]:active:not(:disabled),.o-btn[variant=destructive-ghost][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[isFullWidth]{--btn-inline-size: 100%}.o-btn[disabled]{--btn-text-color: var(--dt-color-content-disabled) !important;cursor:not-allowed}.o-btn[disabled]:not([variant=ghost],[variant=ghost-inverse],[variant=destructive-ghost]){--btn-bg-color: var(--dt-color-disabled-01) !important}.o-btn[disabled][variant=outline]{border-color:var(--dt-color-disabled-01)!important}.o-btn[size=xsmall]{--btn-height: var(--btn-height--xsmall);--btn-padding: 6px var(--dt-spacing-b);--btn-font-size: calc(var(--dt-font-size-14) * 1px);--btn-line-height: calc(var(--dt-font-size-14-line-height) * 1px);--btn-icon-size: 16px}.o-btn[size=small-expressive],.o-btn[size=small-productive]{--btn-height: var(--btn-height--small);--btn-icon-size: 20px}.o-btn[size=small-expressive]{--btn-padding: 6px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px)}.o-btn[size=small-productive]{--btn-padding: 8px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-16) * 1px);--btn-line-height: calc(var(--dt-font-size-16-line-height) * 1px)}.o-btn[size=large]{--btn-height: var(--btn-height--large);--btn-padding: 14px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px)}.o-btn[isLoading]>*:not(pie-spinner){visibility:hidden}.o-btn[isLoading] pie-spinner{position:absolute}.o-btn:focus-visible{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}::slotted(svg){height:var(--btn-icon-size);width:var(--btn-icon-size)}
|
|
33
34
|
`;
|
|
34
35
|
(function() {
|
|
35
|
-
const d = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(),
|
|
36
|
+
const d = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new WeakMap(), I = {
|
|
36
37
|
ariaAtomic: "aria-atomic",
|
|
37
38
|
ariaAutoComplete: "aria-autocomplete",
|
|
38
39
|
ariaBusy: "aria-busy",
|
|
@@ -75,10 +76,10 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
75
76
|
ariaValueText: "aria-valuetext",
|
|
76
77
|
role: "role"
|
|
77
78
|
}, it = (r, t) => {
|
|
78
|
-
for (let e in
|
|
79
|
+
for (let e in I) {
|
|
79
80
|
t[e] = null;
|
|
80
81
|
let o = null;
|
|
81
|
-
const i =
|
|
82
|
+
const i = I[e];
|
|
82
83
|
Object.defineProperty(t, e, {
|
|
83
84
|
get() {
|
|
84
85
|
return o;
|
|
@@ -89,11 +90,11 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
};
|
|
92
|
-
function
|
|
93
|
+
function q(r) {
|
|
93
94
|
const t = c.get(r), { form: e } = t;
|
|
94
|
-
|
|
95
|
+
X(r, e, t), Q(r, t.labels);
|
|
95
96
|
}
|
|
96
|
-
const
|
|
97
|
+
const U = (r, t = !1) => {
|
|
97
98
|
const e = document.createTreeWalker(r, NodeFilter.SHOW_ELEMENT, {
|
|
98
99
|
acceptNode(l) {
|
|
99
100
|
return c.has(l) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
@@ -102,45 +103,45 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
102
103
|
let o = e.nextNode();
|
|
103
104
|
const i = !t || r.disabled;
|
|
104
105
|
for (; o; )
|
|
105
|
-
o.formDisabledCallback && i &&
|
|
106
|
-
},
|
|
106
|
+
o.formDisabledCallback && i && D(o, r.disabled), o = e.nextNode();
|
|
107
|
+
}, j = { attributes: !0, attributeFilter: ["disabled", "name"] }, k = S() ? new MutationObserver((r) => {
|
|
107
108
|
for (const t of r) {
|
|
108
109
|
const e = t.target;
|
|
109
|
-
if (t.attributeName === "disabled" && (e.constructor.formAssociated ?
|
|
110
|
+
if (t.attributeName === "disabled" && (e.constructor.formAssociated ? D(e, e.hasAttribute("disabled")) : e.localName === "fieldset" && U(e)), t.attributeName === "name" && e.constructor.formAssociated) {
|
|
110
111
|
const o = c.get(e), i = L.get(e);
|
|
111
112
|
o.setFormValue(i);
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
}) : {};
|
|
115
|
-
function
|
|
116
|
+
function _(r) {
|
|
116
117
|
r.forEach((t) => {
|
|
117
118
|
const { addedNodes: e, removedNodes: o } = t, i = Array.from(e), l = Array.from(o);
|
|
118
119
|
i.forEach((s) => {
|
|
119
|
-
var
|
|
120
|
-
if (c.has(s) && s.constructor.formAssociated &&
|
|
120
|
+
var f;
|
|
121
|
+
if (c.has(s) && s.constructor.formAssociated && q(s), F.has(s)) {
|
|
121
122
|
const v = F.get(s);
|
|
122
|
-
Object.keys(
|
|
123
|
-
s.setAttribute(
|
|
123
|
+
Object.keys(I).filter((w) => v[w] !== null).forEach((w) => {
|
|
124
|
+
s.setAttribute(I[w], v[w]);
|
|
124
125
|
}), F.delete(s);
|
|
125
126
|
}
|
|
126
|
-
if (
|
|
127
|
-
const v =
|
|
128
|
-
s.setAttribute("internals-valid", v.validity.valid.toString()), s.setAttribute("internals-invalid", (!v.validity.valid).toString()), s.setAttribute("aria-invalid", (!v.validity.valid).toString()),
|
|
127
|
+
if (A.has(s)) {
|
|
128
|
+
const v = A.get(s);
|
|
129
|
+
s.setAttribute("internals-valid", v.validity.valid.toString()), s.setAttribute("internals-invalid", (!v.validity.valid).toString()), s.setAttribute("aria-invalid", (!v.validity.valid).toString()), A.delete(s);
|
|
129
130
|
}
|
|
130
131
|
if (s.localName === "form") {
|
|
131
|
-
const v =
|
|
132
|
-
acceptNode(
|
|
133
|
-
return c.has(
|
|
132
|
+
const v = u.get(s), x = document.createTreeWalker(s, NodeFilter.SHOW_ELEMENT, {
|
|
133
|
+
acceptNode(ot) {
|
|
134
|
+
return c.has(ot) && !(v && v.has(ot)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
134
135
|
}
|
|
135
136
|
});
|
|
136
137
|
let w = x.nextNode();
|
|
137
138
|
for (; w; )
|
|
138
|
-
|
|
139
|
+
q(w), w = x.nextNode();
|
|
139
140
|
}
|
|
140
|
-
s.localName === "fieldset" && ((
|
|
141
|
+
s.localName === "fieldset" && ((f = k.observe) == null || f.call(k, s, j), U(s, !0));
|
|
141
142
|
}), l.forEach((s) => {
|
|
142
|
-
const
|
|
143
|
-
|
|
143
|
+
const f = c.get(s);
|
|
144
|
+
f && a.get(f) && G(f), m.has(s) && m.get(s).disconnect();
|
|
144
145
|
});
|
|
145
146
|
});
|
|
146
147
|
}
|
|
@@ -148,88 +149,88 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
148
149
|
r.forEach((t) => {
|
|
149
150
|
const { removedNodes: e } = t;
|
|
150
151
|
e.forEach((o) => {
|
|
151
|
-
const i =
|
|
152
|
-
c.has(o) &&
|
|
152
|
+
const i = B.get(t.target);
|
|
153
|
+
c.has(o) && Z(o), i.disconnect();
|
|
153
154
|
});
|
|
154
155
|
});
|
|
155
156
|
}
|
|
156
157
|
const nt = (r) => {
|
|
157
158
|
var e;
|
|
158
159
|
const t = new MutationObserver(at);
|
|
159
|
-
(e = t.observe) == null || e.call(t, r, { childList: !0 }),
|
|
160
|
+
(e = t.observe) == null || e.call(t, r, { childList: !0 }), B.set(r, t);
|
|
160
161
|
};
|
|
161
|
-
S() && new MutationObserver(
|
|
162
|
-
const
|
|
162
|
+
S() && new MutationObserver(_);
|
|
163
|
+
const $ = {
|
|
163
164
|
childList: !0,
|
|
164
165
|
subtree: !0
|
|
165
|
-
},
|
|
166
|
+
}, D = (r, t) => {
|
|
166
167
|
r.toggleAttribute("internals-disabled", t), t ? r.setAttribute("aria-disabled", "true") : r.removeAttribute("aria-disabled"), r.formDisabledCallback && r.formDisabledCallback.apply(r, [t]);
|
|
167
|
-
},
|
|
168
|
+
}, G = (r) => {
|
|
168
169
|
a.get(r).forEach((e) => {
|
|
169
170
|
e.remove();
|
|
170
171
|
}), a.set(r, []);
|
|
171
|
-
},
|
|
172
|
+
}, J = (r, t) => {
|
|
172
173
|
const e = document.createElement("input");
|
|
173
174
|
return e.type = "hidden", e.name = r.getAttribute("name"), r.after(e), a.get(t).push(e), e;
|
|
174
175
|
}, st = (r, t) => {
|
|
175
176
|
var e;
|
|
176
|
-
a.set(t, []), (e = k.observe) == null || e.call(k, r,
|
|
177
|
-
},
|
|
177
|
+
a.set(t, []), (e = k.observe) == null || e.call(k, r, j);
|
|
178
|
+
}, Q = (r, t) => {
|
|
178
179
|
if (t.length) {
|
|
179
180
|
Array.from(t).forEach((o) => o.addEventListener("click", r.click.bind(r)));
|
|
180
181
|
let e = t[0].id;
|
|
181
182
|
t[0].id || (e = `${t[0].htmlFor}_Label`, t[0].id = e), r.setAttribute("aria-labelledby", e);
|
|
182
183
|
}
|
|
183
|
-
},
|
|
184
|
-
const t = Array.from(r.elements).filter((l) => !l.tagName.includes("-") && l.validity).map((l) => l.validity.valid), e =
|
|
184
|
+
}, T = (r) => {
|
|
185
|
+
const t = Array.from(r.elements).filter((l) => !l.tagName.includes("-") && l.validity).map((l) => l.validity.valid), e = u.get(r) || [], o = Array.from(e).filter((l) => l.isConnected).map((l) => c.get(l).validity.valid), i = [...t, ...o].includes(!1);
|
|
185
186
|
r.toggleAttribute("internals-invalid", i), r.toggleAttribute("internals-valid", !i);
|
|
186
187
|
}, lt = (r) => {
|
|
187
|
-
|
|
188
|
+
T(z(r.target));
|
|
188
189
|
}, ct = (r) => {
|
|
189
|
-
|
|
190
|
+
T(z(r.target));
|
|
190
191
|
}, dt = (r) => {
|
|
191
192
|
const t = ["button[type=submit]", "input[type=submit]", "button:not([type])"].map((e) => `${e}:not([disabled])`).map((e) => `${e}:not([form])${r.id ? `,${e}[form='${r.id}']` : ""}`).join(",");
|
|
192
193
|
r.addEventListener("click", (e) => {
|
|
193
194
|
if (e.target.closest(t)) {
|
|
194
|
-
const i =
|
|
195
|
+
const i = u.get(r);
|
|
195
196
|
if (r.noValidate)
|
|
196
197
|
return;
|
|
197
|
-
i.size && Array.from(i).reverse().map((
|
|
198
|
+
i.size && Array.from(i).reverse().map((f) => c.get(f).reportValidity()).includes(!1) && e.preventDefault();
|
|
198
199
|
}
|
|
199
200
|
});
|
|
200
201
|
}, vt = (r) => {
|
|
201
|
-
const t =
|
|
202
|
+
const t = u.get(r.target);
|
|
202
203
|
t && t.size && t.forEach((e) => {
|
|
203
204
|
e.constructor.formAssociated && e.formResetCallback && e.formResetCallback.apply(e);
|
|
204
205
|
});
|
|
205
|
-
},
|
|
206
|
+
}, X = (r, t, e) => {
|
|
206
207
|
if (t) {
|
|
207
|
-
const o =
|
|
208
|
+
const o = u.get(t);
|
|
208
209
|
if (o)
|
|
209
210
|
o.add(r);
|
|
210
211
|
else {
|
|
211
212
|
const i = /* @__PURE__ */ new Set();
|
|
212
|
-
i.add(r),
|
|
213
|
+
i.add(r), u.set(t, i), dt(t), t.addEventListener("reset", vt), t.addEventListener("input", lt), t.addEventListener("change", ct);
|
|
213
214
|
}
|
|
214
215
|
y.set(t, { ref: r, internals: e }), r.constructor.formAssociated && r.formAssociatedCallback && setTimeout(() => {
|
|
215
216
|
r.formAssociatedCallback.apply(r, [t]);
|
|
216
|
-
}, 0),
|
|
217
|
+
}, 0), T(t);
|
|
217
218
|
}
|
|
218
|
-
},
|
|
219
|
+
}, z = (r) => {
|
|
219
220
|
let t = r.parentNode;
|
|
220
|
-
return t && t.tagName !== "FORM" && (t =
|
|
221
|
+
return t && t.tagName !== "FORM" && (t = z(t)), t;
|
|
221
222
|
}, E = (r, t, e = DOMException) => {
|
|
222
223
|
if (!r.constructor.formAssociated)
|
|
223
224
|
throw new e(t);
|
|
224
|
-
},
|
|
225
|
-
const o =
|
|
225
|
+
}, Y = (r, t, e) => {
|
|
226
|
+
const o = u.get(r);
|
|
226
227
|
return o && o.size && o.forEach((i) => {
|
|
227
228
|
c.get(i)[e]() || (t = !1);
|
|
228
229
|
}), t;
|
|
229
|
-
},
|
|
230
|
+
}, Z = (r) => {
|
|
230
231
|
if (r.constructor.formAssociated) {
|
|
231
232
|
const t = c.get(r), { labels: e, form: o } = t;
|
|
232
|
-
|
|
233
|
+
Q(r, e), X(r, o, t);
|
|
233
234
|
}
|
|
234
235
|
};
|
|
235
236
|
function S() {
|
|
@@ -240,13 +241,13 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
240
241
|
this.badInput = !1, this.customError = !1, this.patternMismatch = !1, this.rangeOverflow = !1, this.rangeUnderflow = !1, this.stepMismatch = !1, this.tooLong = !1, this.tooShort = !1, this.typeMismatch = !1, this.valid = !0, this.valueMissing = !1, Object.seal(this);
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
|
-
const
|
|
244
|
+
const mt = (r) => (r.badInput = !1, r.customError = !1, r.patternMismatch = !1, r.rangeOverflow = !1, r.rangeUnderflow = !1, r.stepMismatch = !1, r.tooLong = !1, r.tooShort = !1, r.typeMismatch = !1, r.valid = !0, r.valueMissing = !1, r), ut = (r, t, e) => (r.valid = pt(t), Object.keys(t).forEach((o) => r[o] = t[o]), e && T(e), r), pt = (r) => {
|
|
244
245
|
let t = !0;
|
|
245
246
|
for (let e in r)
|
|
246
247
|
e !== "valid" && r[e] !== !1 && (t = !1);
|
|
247
248
|
return t;
|
|
248
|
-
},
|
|
249
|
-
function
|
|
249
|
+
}, O = /* @__PURE__ */ new WeakMap();
|
|
250
|
+
function tt(r, t) {
|
|
250
251
|
r.toggleAttribute(t, !0), r.part && r.part.add(t);
|
|
251
252
|
}
|
|
252
253
|
class V extends Set {
|
|
@@ -256,14 +257,14 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
256
257
|
constructor(t) {
|
|
257
258
|
if (super(), !t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
258
259
|
throw new TypeError("Illegal constructor");
|
|
259
|
-
|
|
260
|
+
O.set(this, t);
|
|
260
261
|
}
|
|
261
262
|
add(t) {
|
|
262
263
|
if (!/^--/.test(t) || typeof t != "string")
|
|
263
264
|
throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${t} must start with '--'.`);
|
|
264
|
-
const e = super.add(t), o =
|
|
265
|
-
return o.isConnected ?
|
|
266
|
-
|
|
265
|
+
const e = super.add(t), o = O.get(this), i = `state${t}`;
|
|
266
|
+
return o.isConnected ? tt(o, i) : setTimeout(() => {
|
|
267
|
+
tt(o, i);
|
|
267
268
|
}), e;
|
|
268
269
|
}
|
|
269
270
|
clear() {
|
|
@@ -272,20 +273,20 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
272
273
|
super.clear();
|
|
273
274
|
}
|
|
274
275
|
delete(t) {
|
|
275
|
-
const e = super.delete(t), o =
|
|
276
|
+
const e = super.delete(t), o = O.get(this);
|
|
276
277
|
return o.isConnected ? (o.toggleAttribute(`state${t}`, !1), o.part && o.part.remove(`state${t}`)) : setTimeout(() => {
|
|
277
278
|
o.toggleAttribute(`state${t}`, !1), o.part && o.part.remove(`state${t}`);
|
|
278
279
|
}), e;
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
|
-
function
|
|
282
|
+
function et(r, t, e, o) {
|
|
282
283
|
if (e === "a" && !o)
|
|
283
284
|
throw new TypeError("Private accessor was defined without a getter");
|
|
284
285
|
if (typeof t == "function" ? r !== t || !o : !t.has(r))
|
|
285
286
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
286
287
|
return e === "m" ? o : e === "a" ? o.call(r) : o ? o.value : t.get(r);
|
|
287
288
|
}
|
|
288
|
-
function
|
|
289
|
+
function ft(r, t, e, o, i) {
|
|
289
290
|
if (o === "m")
|
|
290
291
|
throw new TypeError("Private method is not writable");
|
|
291
292
|
if (o === "a" && !i)
|
|
@@ -295,9 +296,9 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
295
296
|
return o === "a" ? i.call(r, e) : i ? i.value = e : t.set(r, e), e;
|
|
296
297
|
}
|
|
297
298
|
var M;
|
|
298
|
-
class
|
|
299
|
+
class bt {
|
|
299
300
|
constructor(t) {
|
|
300
|
-
M.set(this, void 0),
|
|
301
|
+
M.set(this, void 0), ft(this, M, t, "f");
|
|
301
302
|
for (let e = 0; e < t.length; e++) {
|
|
302
303
|
let o = t[e];
|
|
303
304
|
this[e] = o, o.hasAttribute("name") && (this[o.getAttribute("name")] = o);
|
|
@@ -305,10 +306,10 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
305
306
|
Object.freeze(this);
|
|
306
307
|
}
|
|
307
308
|
get length() {
|
|
308
|
-
return
|
|
309
|
+
return et(this, M, "f").length;
|
|
309
310
|
}
|
|
310
311
|
[(M = /* @__PURE__ */ new WeakMap(), Symbol.iterator)]() {
|
|
311
|
-
return
|
|
312
|
+
return et(this, M, "f")[Symbol.iterator]();
|
|
312
313
|
}
|
|
313
314
|
item(t) {
|
|
314
315
|
return this[t] == null ? null : this[t];
|
|
@@ -324,24 +325,24 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
324
325
|
HTMLFormElement.prototype.reportValidity = o;
|
|
325
326
|
function e(...l) {
|
|
326
327
|
let s = r.apply(this, l);
|
|
327
|
-
return
|
|
328
|
+
return Y(this, s, "checkValidity");
|
|
328
329
|
}
|
|
329
330
|
function o(...l) {
|
|
330
331
|
let s = t.apply(this, l);
|
|
331
|
-
return
|
|
332
|
+
return Y(this, s, "reportValidity");
|
|
332
333
|
}
|
|
333
334
|
const { get: i } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
|
|
334
335
|
Object.defineProperty(HTMLFormElement.prototype, "elements", {
|
|
335
336
|
get(...l) {
|
|
336
|
-
const s = i.call(this, ...l),
|
|
337
|
-
if (
|
|
337
|
+
const s = i.call(this, ...l), f = Array.from(u.get(this) || []);
|
|
338
|
+
if (f.length === 0)
|
|
338
339
|
return s;
|
|
339
|
-
const v = Array.from(s).concat(
|
|
340
|
-
return new
|
|
340
|
+
const v = Array.from(s).concat(f).sort((x, w) => x.compareDocumentPosition ? x.compareDocumentPosition(w) & 2 ? 1 : -1 : 0);
|
|
341
|
+
return new bt(v);
|
|
341
342
|
}
|
|
342
343
|
});
|
|
343
344
|
}
|
|
344
|
-
class
|
|
345
|
+
class rt {
|
|
345
346
|
static get isPolyfilled() {
|
|
346
347
|
return !0;
|
|
347
348
|
}
|
|
@@ -370,7 +371,7 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
370
371
|
const t = d.get(this);
|
|
371
372
|
E(t, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
372
373
|
let e;
|
|
373
|
-
return t.constructor.formAssociated === !0 && (e =
|
|
374
|
+
return t.constructor.formAssociated === !0 && (e = z(t)), e;
|
|
374
375
|
}
|
|
375
376
|
get labels() {
|
|
376
377
|
const t = d.get(this);
|
|
@@ -382,22 +383,22 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
382
383
|
const t = d.get(this);
|
|
383
384
|
if (E(t, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
384
385
|
return !0;
|
|
385
|
-
const e = this.checkValidity(), o =
|
|
386
|
+
const e = this.checkValidity(), o = H.get(this);
|
|
386
387
|
if (o && !t.constructor.formAssociated)
|
|
387
388
|
throw new DOMException("Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.");
|
|
388
389
|
return !e && o && (t.focus(), o.focus()), e;
|
|
389
390
|
}
|
|
390
391
|
setFormValue(t) {
|
|
391
392
|
const e = d.get(this);
|
|
392
|
-
if (E(e, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."),
|
|
393
|
+
if (E(e, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."), G(this), t != null && !(t instanceof FormData)) {
|
|
393
394
|
if (e.getAttribute("name")) {
|
|
394
|
-
const o =
|
|
395
|
+
const o = J(e, this);
|
|
395
396
|
o.value = t;
|
|
396
397
|
}
|
|
397
398
|
} else
|
|
398
399
|
t != null && t instanceof FormData && Array.from(t).reverse().forEach(([o, i]) => {
|
|
399
400
|
if (typeof i == "string") {
|
|
400
|
-
const l =
|
|
401
|
+
const l = J(e, this);
|
|
401
402
|
l.name = o, l.value = i;
|
|
402
403
|
}
|
|
403
404
|
});
|
|
@@ -407,25 +408,25 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
407
408
|
const i = d.get(this);
|
|
408
409
|
if (E(i, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !t)
|
|
409
410
|
throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.");
|
|
410
|
-
|
|
411
|
+
H.set(this, o);
|
|
411
412
|
const l = n.get(this), s = {};
|
|
412
413
|
for (const x in t)
|
|
413
414
|
s[x] = t[x];
|
|
414
|
-
Object.keys(s).length === 0 &&
|
|
415
|
-
const
|
|
416
|
-
delete
|
|
417
|
-
const { valid: v } =
|
|
415
|
+
Object.keys(s).length === 0 && mt(l);
|
|
416
|
+
const f = { ...l, ...s };
|
|
417
|
+
delete f.valid;
|
|
418
|
+
const { valid: v } = ut(l, f, this.form);
|
|
418
419
|
if (!v && !e)
|
|
419
420
|
throw new DOMException("Failed to execute 'setValidity' on 'ElementInternals': The second argument should not be empty if one or more flags in the first argument are true.");
|
|
420
|
-
|
|
421
|
+
p.set(this, v ? "" : e), i.isConnected ? (i.toggleAttribute("internals-invalid", !v), i.toggleAttribute("internals-valid", v), i.setAttribute("aria-invalid", `${!v}`)) : A.set(i, this);
|
|
421
422
|
}
|
|
422
423
|
get shadowRoot() {
|
|
423
|
-
const t = d.get(this), e =
|
|
424
|
+
const t = d.get(this), e = W.get(t);
|
|
424
425
|
return e || null;
|
|
425
426
|
}
|
|
426
427
|
get validationMessage() {
|
|
427
428
|
const t = d.get(this);
|
|
428
|
-
return E(t, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."),
|
|
429
|
+
return E(t, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), p.get(this);
|
|
429
430
|
}
|
|
430
431
|
get validity() {
|
|
431
432
|
const t = d.get(this);
|
|
@@ -470,13 +471,13 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
470
471
|
};
|
|
471
472
|
}
|
|
472
473
|
} else {
|
|
473
|
-
if (typeof window < "u" && (window.ElementInternals =
|
|
474
|
+
if (typeof window < "u" && (window.ElementInternals = rt), typeof CustomElementRegistry < "u") {
|
|
474
475
|
const r = CustomElementRegistry.prototype.define;
|
|
475
476
|
CustomElementRegistry.prototype.define = function(t, e, o) {
|
|
476
477
|
if (e.formAssociated) {
|
|
477
478
|
const i = e.prototype.connectedCallback;
|
|
478
479
|
e.prototype.connectedCallback = function() {
|
|
479
|
-
|
|
480
|
+
K.has(this) || (K.set(this, !0), this.hasAttribute("disabled") && D(this, !0)), i != null && i.apply(this), Z(this);
|
|
480
481
|
};
|
|
481
482
|
}
|
|
482
483
|
r.call(this, t, e, o);
|
|
@@ -490,26 +491,26 @@ const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
490
491
|
return {};
|
|
491
492
|
if (c.has(this))
|
|
492
493
|
throw new DOMException("DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");
|
|
493
|
-
return new
|
|
494
|
+
return new rt(this);
|
|
494
495
|
}), typeof Element < "u") {
|
|
495
496
|
let r = function(...e) {
|
|
496
497
|
const o = t.apply(this, e);
|
|
497
|
-
if (
|
|
498
|
-
const i = new MutationObserver(
|
|
499
|
-
window.ShadyDOM ? i.observe(this,
|
|
498
|
+
if (W.set(this, o), S()) {
|
|
499
|
+
const i = new MutationObserver(_);
|
|
500
|
+
window.ShadyDOM ? i.observe(this, $) : i.observe(o, $), m.set(this, i);
|
|
500
501
|
}
|
|
501
502
|
return o;
|
|
502
503
|
};
|
|
503
504
|
const t = Element.prototype.attachShadow;
|
|
504
505
|
Element.prototype.attachShadow = r;
|
|
505
506
|
}
|
|
506
|
-
S() && typeof document < "u" && new MutationObserver(
|
|
507
|
+
S() && typeof document < "u" && new MutationObserver(_).observe(document.documentElement, $), typeof HTMLFormElement < "u" && gt(), typeof window < "u" && !window.CustomStateSet && (window.CustomStateSet = V);
|
|
507
508
|
}
|
|
508
509
|
})();
|
|
509
|
-
var
|
|
510
|
-
for (var
|
|
511
|
-
(
|
|
512
|
-
return c &&
|
|
510
|
+
var At = Object.defineProperty, It = Object.getOwnPropertyDescriptor, g = (d, n, a, c) => {
|
|
511
|
+
for (var p = c > 1 ? void 0 : c ? It(n, a) : n, y = d.length - 1, m; y >= 0; y--)
|
|
512
|
+
(m = d[y]) && (p = (c ? m(n, a, p) : m(p)) || p);
|
|
513
|
+
return c && p && At(n, a, p), p;
|
|
513
514
|
};
|
|
514
515
|
const C = "pie-button";
|
|
515
516
|
class h extends Et {
|
|
@@ -557,29 +558,43 @@ class h extends Et {
|
|
|
557
558
|
_handleClick() {
|
|
558
559
|
!this.isLoading && this.form && (this.type === "submit" && (this.formnovalidate || this.form.reportValidity()) && this._simulateNativeButtonClick("submit"), this.type === "reset" && this._simulateNativeButtonClick("reset"));
|
|
559
560
|
}
|
|
561
|
+
/**
|
|
562
|
+
* Template for the loading state
|
|
563
|
+
*
|
|
564
|
+
* @private
|
|
565
|
+
*/
|
|
566
|
+
renderSpinner() {
|
|
567
|
+
const n = this.size.includes("small") ? "s" : "m", c = ["primary", "destructive", "outline-inverse", "ghost-inverse"].includes(this.variant) ? "inverse" : "secondary";
|
|
568
|
+
return N`
|
|
569
|
+
<pie-spinner
|
|
570
|
+
size="${n}"
|
|
571
|
+
variant="${c}"
|
|
572
|
+
</pie-spinner>`;
|
|
573
|
+
}
|
|
560
574
|
render() {
|
|
561
575
|
const {
|
|
562
576
|
type: n,
|
|
563
577
|
disabled: a,
|
|
564
578
|
isFullWidth: c,
|
|
565
|
-
variant:
|
|
579
|
+
variant: p,
|
|
566
580
|
size: y,
|
|
567
|
-
isLoading:
|
|
568
|
-
iconPlacement:
|
|
581
|
+
isLoading: m,
|
|
582
|
+
iconPlacement: u
|
|
569
583
|
} = this;
|
|
570
|
-
return
|
|
584
|
+
return N`
|
|
571
585
|
<button
|
|
572
586
|
@click=${this._handleClick}
|
|
573
587
|
class="o-btn"
|
|
574
588
|
type=${n}
|
|
575
|
-
variant=${
|
|
589
|
+
variant=${p}
|
|
576
590
|
size=${y}
|
|
577
591
|
?disabled=${a}
|
|
578
592
|
?isFullWidth=${c}
|
|
579
|
-
?isLoading=${
|
|
580
|
-
${
|
|
593
|
+
?isLoading=${m}>
|
|
594
|
+
${m ? this.renderSpinner() : R}
|
|
595
|
+
${u === "leading" ? N`<slot name="icon"></slot>` : R}
|
|
581
596
|
<slot></slot>
|
|
582
|
-
${
|
|
597
|
+
${u === "trailing" ? N`<slot name="icon"></slot>` : R}
|
|
583
598
|
</button>`;
|
|
584
599
|
}
|
|
585
600
|
focus() {
|
|
@@ -590,57 +605,57 @@ class h extends Et {
|
|
|
590
605
|
h.formAssociated = !0;
|
|
591
606
|
h.styles = wt(Ft);
|
|
592
607
|
g([
|
|
593
|
-
|
|
594
|
-
|
|
608
|
+
b(),
|
|
609
|
+
P(C, kt, "medium")
|
|
595
610
|
], h.prototype, "size", 2);
|
|
596
611
|
g([
|
|
597
|
-
|
|
598
|
-
|
|
612
|
+
b(),
|
|
613
|
+
P(C, Mt, "submit")
|
|
599
614
|
], h.prototype, "type", 2);
|
|
600
615
|
g([
|
|
601
|
-
|
|
602
|
-
|
|
616
|
+
b(),
|
|
617
|
+
P(C, Ct, "primary")
|
|
603
618
|
], h.prototype, "variant", 2);
|
|
604
619
|
g([
|
|
605
|
-
|
|
606
|
-
|
|
620
|
+
b({ type: String }),
|
|
621
|
+
P(C, Lt, "leading")
|
|
607
622
|
], h.prototype, "iconPlacement", 2);
|
|
608
623
|
g([
|
|
609
|
-
|
|
624
|
+
b({ type: Boolean })
|
|
610
625
|
], h.prototype, "disabled", 2);
|
|
611
626
|
g([
|
|
612
|
-
|
|
627
|
+
b({ type: Boolean, reflect: !0 })
|
|
613
628
|
], h.prototype, "isLoading", 2);
|
|
614
629
|
g([
|
|
615
|
-
|
|
630
|
+
b({ type: Boolean })
|
|
616
631
|
], h.prototype, "isFullWidth", 2);
|
|
617
632
|
g([
|
|
618
|
-
|
|
633
|
+
b({ type: String })
|
|
619
634
|
], h.prototype, "name", 2);
|
|
620
635
|
g([
|
|
621
|
-
|
|
636
|
+
b({ type: String })
|
|
622
637
|
], h.prototype, "value", 2);
|
|
623
638
|
g([
|
|
624
|
-
|
|
639
|
+
b()
|
|
625
640
|
], h.prototype, "formaction", 2);
|
|
626
641
|
g([
|
|
627
|
-
|
|
642
|
+
b()
|
|
628
643
|
], h.prototype, "formenctype", 2);
|
|
629
644
|
g([
|
|
630
|
-
|
|
645
|
+
b()
|
|
631
646
|
], h.prototype, "formmethod", 2);
|
|
632
647
|
g([
|
|
633
|
-
|
|
648
|
+
b({ type: Boolean })
|
|
634
649
|
], h.prototype, "formnovalidate", 2);
|
|
635
650
|
g([
|
|
636
|
-
|
|
651
|
+
b()
|
|
637
652
|
], h.prototype, "formtarget", 2);
|
|
638
653
|
xt(C, h);
|
|
639
654
|
export {
|
|
640
655
|
h as PieButton,
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
656
|
+
Vt as formEncodingtypes,
|
|
657
|
+
Nt as formMethodTypes,
|
|
658
|
+
Pt as formTargetTypes,
|
|
644
659
|
Lt as iconPlacements,
|
|
645
660
|
kt as sizes,
|
|
646
661
|
Mt as types,
|
package/dist/react.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { CSSResult } from 'lit';
|
|
|
2
2
|
import type { LitElement } from 'lit';
|
|
3
3
|
import type { PropertyValues } from 'lit';
|
|
4
4
|
import type { ReactWebComponent } from '@lit-labs/react';
|
|
5
|
-
import type { TemplateResult } from 'lit
|
|
5
|
+
import type { TemplateResult } from 'lit';
|
|
6
6
|
|
|
7
7
|
export declare interface ButtonProps {
|
|
8
8
|
/**
|
|
@@ -121,6 +121,12 @@ declare class PieButton_2 extends LitElement implements ButtonProps {
|
|
|
121
121
|
private _simulateNativeButtonClick;
|
|
122
122
|
private _handleClick;
|
|
123
123
|
private _handleFormKeyDown;
|
|
124
|
+
/**
|
|
125
|
+
* Template for the loading state
|
|
126
|
+
*
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
129
|
+
private renderSpinner;
|
|
124
130
|
render(): TemplateResult<1>;
|
|
125
131
|
focus(): void;
|
|
126
132
|
static styles: CSSResult;
|
package/dist/react.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as w from "react";
|
|
2
2
|
import { PieButton as E } from "./index.js";
|
|
3
|
-
import { formEncodingtypes as
|
|
3
|
+
import { formEncodingtypes as k, formMethodTypes as A, formTargetTypes as D, iconPlacements as G, sizes as H, types as O, variants as S } from "./index.js";
|
|
4
4
|
import "lit";
|
|
5
5
|
import "lit/decorators.js";
|
|
6
|
+
import "@justeattakeaway/pie-spinner";
|
|
6
7
|
/**
|
|
7
8
|
* @license
|
|
8
9
|
* Copyright 2018 Google LLC
|
|
@@ -58,7 +59,7 @@ function B(t = window.React, o, m, p, d) {
|
|
|
58
59
|
const N = i.forwardRef((c, e) => a(f, { ...c, _$Gl: e }, c == null ? void 0 : c.children));
|
|
59
60
|
return N.displayName = f.displayName, N;
|
|
60
61
|
}
|
|
61
|
-
const
|
|
62
|
+
const R = B({
|
|
62
63
|
displayName: "PieButton",
|
|
63
64
|
elementClass: E,
|
|
64
65
|
react: w,
|
|
@@ -66,12 +67,12 @@ const L = B({
|
|
|
66
67
|
events: {}
|
|
67
68
|
});
|
|
68
69
|
export {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
R as PieButton,
|
|
71
|
+
k as formEncodingtypes,
|
|
72
|
+
A as formMethodTypes,
|
|
73
|
+
D as formTargetTypes,
|
|
74
|
+
G as iconPlacements,
|
|
75
|
+
H as sizes,
|
|
76
|
+
O as types,
|
|
77
|
+
S as variants
|
|
77
78
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-button",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"description": "PIE design system button built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,10 +28,7 @@
|
|
|
28
28
|
"author": "Just Eat Takeaway.com - Design System Team",
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@justeattakeaway/pie-components-config": "0.4.0",
|
|
33
|
-
"@justeattakeaway/pie-css": "0.7.0",
|
|
34
|
-
"@justeattakeaway/pie-webc-core": "0.11.0"
|
|
31
|
+
"@justeattakeaway/pie-components-config": "0.5.0"
|
|
35
32
|
},
|
|
36
33
|
"volta": {
|
|
37
34
|
"extends": "../../../package.json"
|
|
@@ -40,6 +37,8 @@
|
|
|
40
37
|
"dist/*.js"
|
|
41
38
|
],
|
|
42
39
|
"dependencies": {
|
|
40
|
+
"@justeattakeaway/pie-spinner": "0.2.1",
|
|
41
|
+
"@justeattakeaway/pie-webc-core": "0.11.0",
|
|
43
42
|
"element-internals-polyfill": "1.3.8"
|
|
44
43
|
}
|
|
45
44
|
}
|
package/src/button.scss
CHANGED
|
@@ -6,27 +6,6 @@
|
|
|
6
6
|
box-sizing: border-box;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Shorthand mixin for updating the HSL custom properties for the loading spinner.
|
|
11
|
-
* Takes in the name of the color to be split into its HSL components.
|
|
12
|
-
*/
|
|
13
|
-
@mixin spinner-base-colors($color) {
|
|
14
|
-
--spinner-base-color-h: var(#{$color}-h);
|
|
15
|
-
--spinner-base-color-s: var(#{$color}-s);
|
|
16
|
-
--spinner-base-color-l: var(#{$color}-l);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Spin animation for loading state
|
|
20
|
-
@keyframes rotate360 {
|
|
21
|
-
from {
|
|
22
|
-
transform: rotate(0deg);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
to {
|
|
26
|
-
transform: rotate(360deg);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
9
|
// Base button styles
|
|
31
10
|
.o-btn {
|
|
32
11
|
// Custom Property Declarations
|
|
@@ -57,26 +36,6 @@
|
|
|
57
36
|
// Set icon size to the medium button icon size (the default state)
|
|
58
37
|
--btn-icon-size: 24px;
|
|
59
38
|
|
|
60
|
-
// Spinner size defaults - currently set for the medium button size (the default state)
|
|
61
|
-
--spinner-size-s: 20px;
|
|
62
|
-
--spinner-size-m: 24px;
|
|
63
|
-
--spinner-border-width-s: 2.5px;
|
|
64
|
-
--spinner-border-width-m: 3px;
|
|
65
|
-
--spinner-size: var(--spinner-size-m);
|
|
66
|
-
--spinner-border-width: var(--spinner-border-width-m);
|
|
67
|
-
|
|
68
|
-
// Spinner colors - currently set for the primary button styles
|
|
69
|
-
@include spinner-base-colors(--dt-color-content-interactive-primary);
|
|
70
|
-
|
|
71
|
-
--spinner-left-color-opacity: 0.35;
|
|
72
|
-
--spinner-left-color: hsl(var(--spinner-base-color-h), var(--spinner-base-color-s), var(--spinner-base-color-l), var(--spinner-left-color-opacity));
|
|
73
|
-
--spinner-right-color: hsl(var(--spinner-base-color-h), var(--spinner-base-color-s), var(--spinner-base-color-l), 1);
|
|
74
|
-
|
|
75
|
-
// Spinner animations
|
|
76
|
-
--spinner-animation-duration: 1.15s;
|
|
77
|
-
--spinner-animation-timing-function: linear;
|
|
78
|
-
--spinner-animation-iteration-count: infinite;
|
|
79
|
-
|
|
80
39
|
position: relative;
|
|
81
40
|
display: flex;
|
|
82
41
|
gap: var(--dt-spacing-b);
|
|
@@ -121,7 +80,6 @@
|
|
|
121
80
|
--btn-text-color: var(--dt-color-content-interactive-secondary);
|
|
122
81
|
|
|
123
82
|
@include p.button-interactive-states('--dt-color-interactive-secondary');
|
|
124
|
-
@include spinner-base-colors('--dt-color-content-interactive-secondary');
|
|
125
83
|
}
|
|
126
84
|
|
|
127
85
|
&[variant='outline'] {
|
|
@@ -133,7 +91,6 @@
|
|
|
133
91
|
// use black as the background color for hover and inverse,
|
|
134
92
|
// as this variant uses a shade of transparent black showing through the container background
|
|
135
93
|
@include p.button-interactive-states('--dt-color-black', 'transparent');
|
|
136
|
-
@include spinner-base-colors('--dt-color-content-interactive-secondary');
|
|
137
94
|
}
|
|
138
95
|
|
|
139
96
|
&[variant='ghost'] {
|
|
@@ -143,7 +100,6 @@
|
|
|
143
100
|
// use black as the background color for hover and inverse,
|
|
144
101
|
// as this variant uses a shade of transparent black showing through the container background
|
|
145
102
|
@include p.button-interactive-states('--dt-color-black', 'transparent');
|
|
146
|
-
@include spinner-base-colors('--dt-color-content-interactive-secondary');
|
|
147
103
|
}
|
|
148
104
|
|
|
149
105
|
&[variant='inverse'] {
|
|
@@ -151,7 +107,6 @@
|
|
|
151
107
|
--btn-text-color: var(--dt-color-content-interactive-secondary);
|
|
152
108
|
|
|
153
109
|
@include p.button-interactive-states('--dt-color-interactive-inverse');
|
|
154
|
-
@include spinner-base-colors('--dt-color-content-interactive-secondary');
|
|
155
110
|
}
|
|
156
111
|
|
|
157
112
|
&[variant='ghost-inverse'],
|
|
@@ -181,7 +136,6 @@
|
|
|
181
136
|
// use black as the background color for hover and inverse,
|
|
182
137
|
// as this variant uses a shade of transparent black showing through the container background
|
|
183
138
|
@include p.button-interactive-states('--dt-color-black', 'transparent');
|
|
184
|
-
@include spinner-base-colors('--dt-color-content-interactive-secondary');
|
|
185
139
|
}
|
|
186
140
|
|
|
187
141
|
// Additional modifiers
|
|
@@ -211,16 +165,12 @@
|
|
|
211
165
|
--btn-font-size: #{p.font-size(--dt-font-size-14)};
|
|
212
166
|
--btn-line-height: calc(var(--dt-font-size-14-line-height) * 1px);
|
|
213
167
|
--btn-icon-size: 16px;
|
|
214
|
-
--spinner-size: var(--spinner-size-s);
|
|
215
|
-
--spinner-border-width: var(--spinner-border-width-s);
|
|
216
168
|
}
|
|
217
169
|
|
|
218
170
|
&[size='small-expressive'],
|
|
219
171
|
&[size='small-productive'] {
|
|
220
172
|
--btn-height: var(--btn-height--small);
|
|
221
173
|
--btn-icon-size: 20px;
|
|
222
|
-
--spinner-size: var(--spinner-size-s);
|
|
223
|
-
--spinner-border-width: var(--spinner-border-width-s);
|
|
224
174
|
}
|
|
225
175
|
|
|
226
176
|
&[size='small-expressive'] {
|
|
@@ -244,34 +194,15 @@
|
|
|
244
194
|
--btn-padding: 14px var(--dt-spacing-e);
|
|
245
195
|
--btn-font-size: #{p.font-size(--dt-font-size-20)};
|
|
246
196
|
--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);
|
|
247
|
-
--spinner-size: var(--spinner-size-m);
|
|
248
|
-
--spinner-border-width: var(--spinner-border-width-m);
|
|
249
197
|
}
|
|
250
198
|
|
|
251
199
|
&[isLoading] {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
// Centre the spinner over the top of the button text
|
|
256
|
-
position: absolute;
|
|
257
|
-
left: 50%;
|
|
258
|
-
top: 50%;
|
|
259
|
-
translate: -50% -50%;
|
|
260
|
-
|
|
261
|
-
height: var(--spinner-size);
|
|
262
|
-
width: var(--spinner-size);
|
|
263
|
-
display: block;
|
|
264
|
-
background-color: transparent;
|
|
265
|
-
border-radius: 50%;
|
|
266
|
-
border-color: var(--spinner-left-color) var(--spinner-right-color) var(--spinner-right-color) var(--spinner-left-color);
|
|
267
|
-
border-width: var(--spinner-border-width);
|
|
268
|
-
border-style: solid;
|
|
269
|
-
will-change: transform;
|
|
270
|
-
animation: rotate360 var(--spinner-animation-duration) var(--spinner-animation-timing-function) var(--spinner-animation-iteration-count);
|
|
200
|
+
& > *:not(pie-spinner) {
|
|
201
|
+
visibility: hidden;
|
|
271
202
|
}
|
|
272
203
|
|
|
273
|
-
|
|
274
|
-
|
|
204
|
+
pie-spinner {
|
|
205
|
+
position: absolute;
|
|
275
206
|
}
|
|
276
207
|
}
|
|
277
208
|
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LitElement, html, unsafeCSS, nothing, PropertyValues,
|
|
2
|
+
LitElement, html, unsafeCSS, nothing, PropertyValues, TemplateResult,
|
|
3
3
|
} from 'lit';
|
|
4
4
|
import { property } from 'lit/decorators.js';
|
|
5
5
|
import { validPropertyValues, defineCustomElement } from '@justeattakeaway/pie-webc-core';
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from './defs';
|
|
9
9
|
import styles from './button.scss?inline';
|
|
10
10
|
import 'element-internals-polyfill';
|
|
11
|
+
import '@justeattakeaway/pie-spinner';
|
|
11
12
|
|
|
12
13
|
// Valid values available to consumers
|
|
13
14
|
export * from './defs';
|
|
@@ -196,6 +197,23 @@ export class PieButton extends LitElement implements ButtonProps {
|
|
|
196
197
|
this._handleClick();
|
|
197
198
|
};
|
|
198
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Template for the loading state
|
|
202
|
+
*
|
|
203
|
+
* @private
|
|
204
|
+
*/
|
|
205
|
+
private renderSpinner (): TemplateResult {
|
|
206
|
+
const spinnerSize = this.size.includes('small') ? 's' : 'm'; // includes("small") matches for any small size value and xsmall
|
|
207
|
+
const inverseVariants: Array<ButtonProps['variant']> = ['primary', 'destructive', 'outline-inverse', 'ghost-inverse'];
|
|
208
|
+
const spinnerVariant = inverseVariants.includes(this.variant) ? 'inverse' : 'secondary';
|
|
209
|
+
|
|
210
|
+
return html`
|
|
211
|
+
<pie-spinner
|
|
212
|
+
size="${spinnerSize}"
|
|
213
|
+
variant="${spinnerVariant}"
|
|
214
|
+
</pie-spinner>`;
|
|
215
|
+
}
|
|
216
|
+
|
|
199
217
|
render () {
|
|
200
218
|
const {
|
|
201
219
|
type,
|
|
@@ -217,6 +235,7 @@ export class PieButton extends LitElement implements ButtonProps {
|
|
|
217
235
|
?disabled=${disabled}
|
|
218
236
|
?isFullWidth=${isFullWidth}
|
|
219
237
|
?isLoading=${isLoading}>
|
|
238
|
+
${isLoading ? this.renderSpinner() : nothing}
|
|
220
239
|
${iconPlacement === 'leading' ? html`<slot name="icon"></slot>` : nothing}
|
|
221
240
|
<slot></slot>
|
|
222
241
|
${iconPlacement === 'trailing' ? html`<slot name="icon"></slot>` : nothing}
|