@justeattakeaway/pie-button 0.34.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -63
- package/dist/index.d.ts +5 -0
- package/dist/index.js +151 -130
- package/dist/react.d.ts +5 -0
- package/dist/react.js +42 -41
- package/package.json +2 -2
- package/src/button.scss +9 -49
- package/src/index.ts +49 -1
package/README.md
CHANGED
|
@@ -14,16 +14,13 @@
|
|
|
14
14
|
2. [Installation](#installation)
|
|
15
15
|
3. [Importing the component](#importing-the-component)
|
|
16
16
|
4. [Peer Dependencies](#peer-dependencies)
|
|
17
|
-
5. [
|
|
18
|
-
6. [
|
|
19
|
-
7. [Events](#events)
|
|
17
|
+
5. [Props](#props)
|
|
18
|
+
6. [Events](#events)
|
|
20
19
|
- [HTML example](#html)
|
|
21
20
|
- [Vue example (using Nuxt 3)](#vue-templates-using-nuxt-3)
|
|
22
21
|
- [React example (using Next 13)](#react-templates-using-next-13)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- [Browser Tests](#browser-tests)
|
|
26
|
-
- [Visual Tests](#visual-tests)
|
|
22
|
+
7. [Forms usage](#forms-usage)
|
|
23
|
+
8. [Contributing](#contributing)
|
|
27
24
|
|
|
28
25
|
|
|
29
26
|
## pie-button
|
|
@@ -71,30 +68,6 @@ import { PieButton } from '@justeattakeaway/pie-button/dist/react';
|
|
|
71
68
|
> When using `pie-button`, you will also need to include a couple of dependencies to ensure the component renders as expected. See [the PIE Wiki for more information and how to include these in your application](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components#expected-dependencies).
|
|
72
69
|
|
|
73
70
|
|
|
74
|
-
## Local development
|
|
75
|
-
|
|
76
|
-
Install the dependencies. Note that this, and the following commands below, should be run from the **root of the monorepo**:
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
yarn
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
To build the `pie-button` package, run the following command:
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
yarn build --filter=pie-button
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
If you'd like to develop using the component storybook, then you should build the component in `watch` mode, and run storybook in a separate terminal tab:
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
yarn watch --filter=pie-button
|
|
92
|
-
|
|
93
|
-
# in a separate terminal tab, run
|
|
94
|
-
yarn dev --filter=pie-storybook
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
|
|
98
71
|
## Props
|
|
99
72
|
|
|
100
73
|
| Property | Type | Default | Description |
|
|
@@ -219,36 +192,6 @@ In this example:
|
|
|
219
192
|
- No validation will be performed during submission, thanks to formnovalidate.
|
|
220
193
|
- The form's submission response will be opened in a new browser tab/window because of the formtarget="_blank" attribute.
|
|
221
194
|
|
|
222
|
-
##
|
|
223
|
-
|
|
224
|
-
### Browser tests
|
|
225
|
-
|
|
226
|
-
To run the browser tests, run the following command from the root of the monorepo:
|
|
195
|
+
## Contributing
|
|
227
196
|
|
|
228
|
-
|
|
229
|
-
yarn test:browsers --filter=pie-button
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### Visual tests
|
|
233
|
-
|
|
234
|
-
To run the visual regression tests, run the following command from the root of the monorepo:
|
|
235
|
-
|
|
236
|
-
```bash
|
|
237
|
-
yarn test:visual --filter=pie-button
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
Note: To run these locally, you will need to ensure that any environment variables required are set up on your machine to mirror those on CI (such as Percy tokens). How you achieve this will differ between operating systems.
|
|
241
|
-
|
|
242
|
-
#### Setup via bash
|
|
243
|
-
|
|
244
|
-
```bash
|
|
245
|
-
export PERCY_TOKEN_PIE_BUTTON=abcde
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
#### Setup via package.json
|
|
249
|
-
|
|
250
|
-
Under scripts `test:visual` replace the environment variable with the below:
|
|
251
|
-
|
|
252
|
-
```bash
|
|
253
|
-
PERCY_TOKEN_PIE_BUTTON=abcde
|
|
254
|
-
```
|
|
197
|
+
Check out our [contributing guide](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide) for more information on [local development](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#local-development) and how to run specific [component tests](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#testing).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSResult } from 'lit';
|
|
2
2
|
import type { LitElement } from 'lit';
|
|
3
|
+
import type { PropertyValues } from 'lit';
|
|
3
4
|
import type { TemplateResult } from 'lit-html';
|
|
4
5
|
|
|
5
6
|
export declare interface ButtonProps {
|
|
@@ -89,6 +90,9 @@ export declare class PieButton extends LitElement implements ButtonProps {
|
|
|
89
90
|
private readonly _internals;
|
|
90
91
|
get form(): HTMLFormElement | null;
|
|
91
92
|
constructor();
|
|
93
|
+
connectedCallback(): void;
|
|
94
|
+
disconnectedCallback(): void;
|
|
95
|
+
updated(changedProperties: PropertyValues<this>): void;
|
|
92
96
|
size: ButtonProps['size'];
|
|
93
97
|
type: ButtonProps['type'];
|
|
94
98
|
variant: ButtonProps['variant'];
|
|
@@ -113,6 +117,7 @@ export declare class PieButton extends LitElement implements ButtonProps {
|
|
|
113
117
|
*/
|
|
114
118
|
private _simulateNativeButtonClick;
|
|
115
119
|
private _handleClick;
|
|
120
|
+
private _handleFormKeyDown;
|
|
116
121
|
render(): TemplateResult<1>;
|
|
117
122
|
focus(): void;
|
|
118
123
|
static styles: CSSResult;
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { unsafeCSS as wt, LitElement as Et, html as
|
|
1
|
+
import { unsafeCSS as wt, LitElement as Et, html as O, nothing as ot } from "lit";
|
|
2
2
|
import { property as f } from "lit/decorators.js";
|
|
3
|
-
const N = (
|
|
3
|
+
const N = (d, n, a) => function(m, y) {
|
|
4
4
|
const b = `#${y}`;
|
|
5
5
|
Object.defineProperty(m, y, {
|
|
6
6
|
get() {
|
|
7
7
|
return this[b];
|
|
8
8
|
},
|
|
9
9
|
set(p) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
`<${
|
|
13
|
-
`Must be one of: ${
|
|
10
|
+
const L = this[b];
|
|
11
|
+
n.includes(p) ? this[b] = p : (console.error(
|
|
12
|
+
`<${d}> Invalid value "${p}" provided for property "${y}".`,
|
|
13
|
+
`Must be one of: ${n.join(" | ")}.`,
|
|
14
14
|
`Falling back to default value: "${a}"`
|
|
15
|
-
), this[b] = a), this.requestUpdate(y,
|
|
15
|
+
), this[b] = a), this.requestUpdate(y, L);
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
|
-
function xt(
|
|
20
|
-
customElements.get(
|
|
19
|
+
function xt(d, n) {
|
|
20
|
+
customElements.get(d) ? console.warn(`PIE Web Component: "${d}" has already been defined. Please ensure the component is only being defined once in your application.`) : customElements.define(d, n);
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"], Mt = ["submit", "button", "reset"], Ct = [
|
|
23
23
|
"primary",
|
|
24
24
|
"secondary",
|
|
25
25
|
"outline",
|
|
@@ -29,10 +29,10 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
29
29
|
"ghost-inverse",
|
|
30
30
|
"destructive",
|
|
31
31
|
"destructive-ghost"
|
|
32
|
-
], Ct = ["leading", "trailing"], St = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], Vt = ["post", "get", "dialog"], Nt = ["_self", "_blank", "_parent", "_top"], At = `*,*: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)}
|
|
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
33
|
`;
|
|
34
34
|
(function() {
|
|
35
|
-
const
|
|
35
|
+
const d = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakMap(), A = {
|
|
36
36
|
ariaAtomic: "aria-atomic",
|
|
37
37
|
ariaAutoComplete: "aria-autocomplete",
|
|
38
38
|
ariaBusy: "aria-busy",
|
|
@@ -75,72 +75,72 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
75
75
|
ariaValueText: "aria-valuetext",
|
|
76
76
|
role: "role"
|
|
77
77
|
}, it = (r, t) => {
|
|
78
|
-
for (let e in
|
|
78
|
+
for (let e in A) {
|
|
79
79
|
t[e] = null;
|
|
80
80
|
let o = null;
|
|
81
|
-
const i =
|
|
81
|
+
const i = A[e];
|
|
82
82
|
Object.defineProperty(t, e, {
|
|
83
83
|
get() {
|
|
84
84
|
return o;
|
|
85
85
|
},
|
|
86
|
-
set(
|
|
87
|
-
o =
|
|
86
|
+
set(l) {
|
|
87
|
+
o = l, r.isConnected ? r.setAttribute(i, l) : F.set(r, t);
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
function
|
|
93
|
-
const t =
|
|
92
|
+
function K(r) {
|
|
93
|
+
const t = c.get(r), { form: e } = t;
|
|
94
94
|
Q(r, e, t), J(r, t.labels);
|
|
95
95
|
}
|
|
96
|
-
const
|
|
96
|
+
const q = (r, t = !1) => {
|
|
97
97
|
const e = document.createTreeWalker(r, NodeFilter.SHOW_ELEMENT, {
|
|
98
|
-
acceptNode(
|
|
99
|
-
return
|
|
98
|
+
acceptNode(l) {
|
|
99
|
+
return c.has(l) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
let o = e.nextNode();
|
|
103
103
|
const i = !t || r.disabled;
|
|
104
104
|
for (; o; )
|
|
105
|
-
o.formDisabledCallback && i &&
|
|
106
|
-
},
|
|
105
|
+
o.formDisabledCallback && i && $(o, r.disabled), o = e.nextNode();
|
|
106
|
+
}, U = { attributes: !0, attributeFilter: ["disabled", "name"] }, k = S() ? new MutationObserver((r) => {
|
|
107
107
|
for (const t of r) {
|
|
108
108
|
const e = t.target;
|
|
109
|
-
if (t.attributeName === "disabled" && (e.constructor.formAssociated ?
|
|
110
|
-
const o =
|
|
109
|
+
if (t.attributeName === "disabled" && (e.constructor.formAssociated ? $(e, e.hasAttribute("disabled")) : e.localName === "fieldset" && q(e)), t.attributeName === "name" && e.constructor.formAssociated) {
|
|
110
|
+
const o = c.get(e), i = L.get(e);
|
|
111
111
|
o.setFormValue(i);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}) : {};
|
|
115
115
|
function P(r) {
|
|
116
116
|
r.forEach((t) => {
|
|
117
|
-
const { addedNodes: e, removedNodes: o } = t, i = Array.from(e),
|
|
118
|
-
i.forEach((
|
|
117
|
+
const { addedNodes: e, removedNodes: o } = t, i = Array.from(e), l = Array.from(o);
|
|
118
|
+
i.forEach((s) => {
|
|
119
119
|
var u;
|
|
120
|
-
if (
|
|
121
|
-
const v =
|
|
122
|
-
Object.keys(
|
|
123
|
-
|
|
124
|
-
}),
|
|
120
|
+
if (c.has(s) && s.constructor.formAssociated && K(s), F.has(s)) {
|
|
121
|
+
const v = F.get(s);
|
|
122
|
+
Object.keys(A).filter((w) => v[w] !== null).forEach((w) => {
|
|
123
|
+
s.setAttribute(A[w], v[w]);
|
|
124
|
+
}), F.delete(s);
|
|
125
125
|
}
|
|
126
|
-
if (
|
|
127
|
-
const v =
|
|
128
|
-
|
|
126
|
+
if (z.has(s)) {
|
|
127
|
+
const v = z.get(s);
|
|
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()), z.delete(s);
|
|
129
129
|
}
|
|
130
|
-
if (
|
|
131
|
-
const v = p.get(
|
|
130
|
+
if (s.localName === "form") {
|
|
131
|
+
const v = p.get(s), x = document.createTreeWalker(s, NodeFilter.SHOW_ELEMENT, {
|
|
132
132
|
acceptNode(rt) {
|
|
133
|
-
return
|
|
133
|
+
return c.has(rt) && !(v && v.has(rt)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
136
|
let w = x.nextNode();
|
|
137
137
|
for (; w; )
|
|
138
|
-
|
|
138
|
+
K(w), w = x.nextNode();
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
}),
|
|
142
|
-
const u =
|
|
143
|
-
u && a.get(u) &&
|
|
140
|
+
s.localName === "fieldset" && ((u = k.observe) == null || u.call(k, s, U), q(s, !0));
|
|
141
|
+
}), l.forEach((s) => {
|
|
142
|
+
const u = c.get(s);
|
|
143
|
+
u && a.get(u) && j(u), b.has(s) && b.get(s).disconnect();
|
|
144
144
|
});
|
|
145
145
|
});
|
|
146
146
|
}
|
|
@@ -148,23 +148,23 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
148
148
|
r.forEach((t) => {
|
|
149
149
|
const { removedNodes: e } = t;
|
|
150
150
|
e.forEach((o) => {
|
|
151
|
-
const i =
|
|
152
|
-
|
|
151
|
+
const i = H.get(t.target);
|
|
152
|
+
c.has(o) && Y(o), i.disconnect();
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
const nt = (r) => {
|
|
157
157
|
var e;
|
|
158
158
|
const t = new MutationObserver(at);
|
|
159
|
-
(e = t.observe) == null || e.call(t, r, { childList: !0 }),
|
|
159
|
+
(e = t.observe) == null || e.call(t, r, { childList: !0 }), H.set(r, t);
|
|
160
160
|
};
|
|
161
161
|
S() && new MutationObserver(P);
|
|
162
|
-
const
|
|
162
|
+
const _ = {
|
|
163
163
|
childList: !0,
|
|
164
164
|
subtree: !0
|
|
165
|
-
},
|
|
165
|
+
}, $ = (r, t) => {
|
|
166
166
|
r.toggleAttribute("internals-disabled", t), t ? r.setAttribute("aria-disabled", "true") : r.removeAttribute("aria-disabled"), r.formDisabledCallback && r.formDisabledCallback.apply(r, [t]);
|
|
167
|
-
},
|
|
167
|
+
}, j = (r) => {
|
|
168
168
|
a.get(r).forEach((e) => {
|
|
169
169
|
e.remove();
|
|
170
170
|
}), a.set(r, []);
|
|
@@ -173,7 +173,7 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
173
173
|
return e.type = "hidden", e.name = r.getAttribute("name"), r.after(e), a.get(t).push(e), e;
|
|
174
174
|
}, st = (r, t) => {
|
|
175
175
|
var e;
|
|
176
|
-
a.set(t, []), (e =
|
|
176
|
+
a.set(t, []), (e = k.observe) == null || e.call(k, r, U);
|
|
177
177
|
}, J = (r, t) => {
|
|
178
178
|
if (t.length) {
|
|
179
179
|
Array.from(t).forEach((o) => o.addEventListener("click", r.click.bind(r)));
|
|
@@ -181,7 +181,7 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
181
181
|
t[0].id || (e = `${t[0].htmlFor}_Label`, t[0].id = e), r.setAttribute("aria-labelledby", e);
|
|
182
182
|
}
|
|
183
183
|
}, I = (r) => {
|
|
184
|
-
const t = Array.from(r.elements).filter((
|
|
184
|
+
const t = Array.from(r.elements).filter((l) => !l.tagName.includes("-") && l.validity).map((l) => l.validity.valid), e = p.get(r) || [], o = Array.from(e).filter((l) => l.isConnected).map((l) => c.get(l).validity.valid), i = [...t, ...o].includes(!1);
|
|
185
185
|
r.toggleAttribute("internals-invalid", i), r.toggleAttribute("internals-valid", !i);
|
|
186
186
|
}, lt = (r) => {
|
|
187
187
|
I(T(r.target));
|
|
@@ -194,7 +194,7 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
194
194
|
const i = p.get(r);
|
|
195
195
|
if (r.noValidate)
|
|
196
196
|
return;
|
|
197
|
-
i.size && Array.from(i).reverse().map((u) =>
|
|
197
|
+
i.size && Array.from(i).reverse().map((u) => c.get(u).reportValidity()).includes(!1) && e.preventDefault();
|
|
198
198
|
}
|
|
199
199
|
});
|
|
200
200
|
}, vt = (r) => {
|
|
@@ -224,11 +224,11 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
224
224
|
}, X = (r, t, e) => {
|
|
225
225
|
const o = p.get(r);
|
|
226
226
|
return o && o.size && o.forEach((i) => {
|
|
227
|
-
|
|
227
|
+
c.get(i)[e]() || (t = !1);
|
|
228
228
|
}), t;
|
|
229
229
|
}, Y = (r) => {
|
|
230
230
|
if (r.constructor.formAssociated) {
|
|
231
|
-
const t =
|
|
231
|
+
const t = c.get(r), { labels: e, form: o } = t;
|
|
232
232
|
J(r, e), Q(r, o, t);
|
|
233
233
|
}
|
|
234
234
|
};
|
|
@@ -245,7 +245,7 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
245
245
|
for (let e in r)
|
|
246
246
|
e !== "valid" && r[e] !== !1 && (t = !1);
|
|
247
247
|
return t;
|
|
248
|
-
},
|
|
248
|
+
}, D = /* @__PURE__ */ new WeakMap();
|
|
249
249
|
function Z(r, t) {
|
|
250
250
|
r.toggleAttribute(t, !0), r.part && r.part.add(t);
|
|
251
251
|
}
|
|
@@ -256,12 +256,12 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
256
256
|
constructor(t) {
|
|
257
257
|
if (super(), !t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
258
258
|
throw new TypeError("Illegal constructor");
|
|
259
|
-
|
|
259
|
+
D.set(this, t);
|
|
260
260
|
}
|
|
261
261
|
add(t) {
|
|
262
262
|
if (!/^--/.test(t) || typeof t != "string")
|
|
263
263
|
throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${t} must start with '--'.`);
|
|
264
|
-
const e = super.add(t), o =
|
|
264
|
+
const e = super.add(t), o = D.get(this), i = `state${t}`;
|
|
265
265
|
return o.isConnected ? Z(o, i) : setTimeout(() => {
|
|
266
266
|
Z(o, i);
|
|
267
267
|
}), e;
|
|
@@ -272,7 +272,7 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
272
272
|
super.clear();
|
|
273
273
|
}
|
|
274
274
|
delete(t) {
|
|
275
|
-
const e = super.delete(t), o =
|
|
275
|
+
const e = super.delete(t), o = D.get(this);
|
|
276
276
|
return o.isConnected ? (o.toggleAttribute(`state${t}`, !1), o.part && o.part.remove(`state${t}`)) : setTimeout(() => {
|
|
277
277
|
o.toggleAttribute(`state${t}`, !1), o.part && o.part.remove(`state${t}`);
|
|
278
278
|
}), e;
|
|
@@ -294,10 +294,10 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
294
294
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
295
295
|
return o === "a" ? i.call(r, e) : i ? i.value = e : t.set(r, e), e;
|
|
296
296
|
}
|
|
297
|
-
var
|
|
297
|
+
var M;
|
|
298
298
|
class ft {
|
|
299
299
|
constructor(t) {
|
|
300
|
-
|
|
300
|
+
M.set(this, void 0), ut(this, M, t, "f");
|
|
301
301
|
for (let e = 0; e < t.length; e++) {
|
|
302
302
|
let o = t[e];
|
|
303
303
|
this[e] = o, o.hasAttribute("name") && (this[o.getAttribute("name")] = o);
|
|
@@ -305,10 +305,10 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
305
305
|
Object.freeze(this);
|
|
306
306
|
}
|
|
307
307
|
get length() {
|
|
308
|
-
return tt(this,
|
|
308
|
+
return tt(this, M, "f").length;
|
|
309
309
|
}
|
|
310
|
-
[(
|
|
311
|
-
return tt(this,
|
|
310
|
+
[(M = /* @__PURE__ */ new WeakMap(), Symbol.iterator)]() {
|
|
311
|
+
return tt(this, M, "f")[Symbol.iterator]();
|
|
312
312
|
}
|
|
313
313
|
item(t) {
|
|
314
314
|
return this[t] == null ? null : this[t];
|
|
@@ -322,21 +322,21 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
322
322
|
HTMLFormElement.prototype.checkValidity = e;
|
|
323
323
|
const t = HTMLFormElement.prototype.reportValidity;
|
|
324
324
|
HTMLFormElement.prototype.reportValidity = o;
|
|
325
|
-
function e(...
|
|
326
|
-
let
|
|
327
|
-
return X(this,
|
|
325
|
+
function e(...l) {
|
|
326
|
+
let s = r.apply(this, l);
|
|
327
|
+
return X(this, s, "checkValidity");
|
|
328
328
|
}
|
|
329
|
-
function o(...
|
|
330
|
-
let
|
|
331
|
-
return X(this,
|
|
329
|
+
function o(...l) {
|
|
330
|
+
let s = t.apply(this, l);
|
|
331
|
+
return X(this, s, "reportValidity");
|
|
332
332
|
}
|
|
333
333
|
const { get: i } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
|
|
334
334
|
Object.defineProperty(HTMLFormElement.prototype, "elements", {
|
|
335
|
-
get(...
|
|
336
|
-
const
|
|
335
|
+
get(...l) {
|
|
336
|
+
const s = i.call(this, ...l), u = Array.from(p.get(this) || []);
|
|
337
337
|
if (u.length === 0)
|
|
338
|
-
return
|
|
339
|
-
const v = Array.from(
|
|
338
|
+
return s;
|
|
339
|
+
const v = Array.from(s).concat(u).sort((x, w) => x.compareDocumentPosition ? x.compareDocumentPosition(w) & 2 ? 1 : -1 : 0);
|
|
340
340
|
return new ft(v);
|
|
341
341
|
}
|
|
342
342
|
});
|
|
@@ -349,13 +349,13 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
349
349
|
if (!t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
350
350
|
throw new TypeError("Illegal constructor");
|
|
351
351
|
const e = t.getRootNode(), o = new ht();
|
|
352
|
-
this.states = new V(t),
|
|
352
|
+
this.states = new V(t), d.set(this, t), n.set(this, o), c.set(t, this), it(t, this), st(t, this), Object.seal(this), e instanceof DocumentFragment && nt(e);
|
|
353
353
|
}
|
|
354
354
|
checkValidity() {
|
|
355
|
-
const t =
|
|
355
|
+
const t = d.get(this);
|
|
356
356
|
if (E(t, "Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
357
357
|
return !0;
|
|
358
|
-
const e =
|
|
358
|
+
const e = n.get(this);
|
|
359
359
|
if (!e.valid) {
|
|
360
360
|
const o = new Event("invalid", {
|
|
361
361
|
bubbles: !1,
|
|
@@ -367,29 +367,29 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
367
367
|
return e.valid;
|
|
368
368
|
}
|
|
369
369
|
get form() {
|
|
370
|
-
const t =
|
|
370
|
+
const t = d.get(this);
|
|
371
371
|
E(t, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
372
372
|
let e;
|
|
373
373
|
return t.constructor.formAssociated === !0 && (e = T(t)), e;
|
|
374
374
|
}
|
|
375
375
|
get labels() {
|
|
376
|
-
const t =
|
|
376
|
+
const t = d.get(this);
|
|
377
377
|
E(t, "Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
378
378
|
const e = t.getAttribute("id"), o = t.getRootNode();
|
|
379
379
|
return o && e ? o.querySelectorAll(`[for="${e}"]`) : [];
|
|
380
380
|
}
|
|
381
381
|
reportValidity() {
|
|
382
|
-
const t =
|
|
382
|
+
const t = d.get(this);
|
|
383
383
|
if (E(t, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
384
384
|
return !0;
|
|
385
|
-
const e = this.checkValidity(), o =
|
|
385
|
+
const e = this.checkValidity(), o = W.get(this);
|
|
386
386
|
if (o && !t.constructor.formAssociated)
|
|
387
387
|
throw new DOMException("Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.");
|
|
388
388
|
return !e && o && (t.focus(), o.focus()), e;
|
|
389
389
|
}
|
|
390
390
|
setFormValue(t) {
|
|
391
|
-
const e =
|
|
392
|
-
if (E(e, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."),
|
|
391
|
+
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."), j(this), t != null && !(t instanceof FormData)) {
|
|
393
393
|
if (e.getAttribute("name")) {
|
|
394
394
|
const o = G(e, this);
|
|
395
395
|
o.value = t;
|
|
@@ -397,42 +397,42 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
397
397
|
} else
|
|
398
398
|
t != null && t instanceof FormData && Array.from(t).reverse().forEach(([o, i]) => {
|
|
399
399
|
if (typeof i == "string") {
|
|
400
|
-
const
|
|
401
|
-
|
|
400
|
+
const l = G(e, this);
|
|
401
|
+
l.name = o, l.value = i;
|
|
402
402
|
}
|
|
403
403
|
});
|
|
404
|
-
|
|
404
|
+
L.set(e, t);
|
|
405
405
|
}
|
|
406
406
|
setValidity(t, e, o) {
|
|
407
|
-
const i =
|
|
407
|
+
const i = d.get(this);
|
|
408
408
|
if (E(i, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !t)
|
|
409
409
|
throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.");
|
|
410
|
-
|
|
411
|
-
const
|
|
410
|
+
W.set(this, o);
|
|
411
|
+
const l = n.get(this), s = {};
|
|
412
412
|
for (const x in t)
|
|
413
|
-
|
|
414
|
-
Object.keys(
|
|
415
|
-
const u = { ...
|
|
413
|
+
s[x] = t[x];
|
|
414
|
+
Object.keys(s).length === 0 && pt(l);
|
|
415
|
+
const u = { ...l, ...s };
|
|
416
416
|
delete u.valid;
|
|
417
|
-
const { valid: v } = mt(
|
|
417
|
+
const { valid: v } = mt(l, u, this.form);
|
|
418
418
|
if (!v && !e)
|
|
419
419
|
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
|
-
m.set(this, v ? "" : e), i.isConnected ? (i.toggleAttribute("internals-invalid", !v), i.toggleAttribute("internals-valid", v), i.setAttribute("aria-invalid", `${!v}`)) :
|
|
420
|
+
m.set(this, v ? "" : e), i.isConnected ? (i.toggleAttribute("internals-invalid", !v), i.toggleAttribute("internals-valid", v), i.setAttribute("aria-invalid", `${!v}`)) : z.set(i, this);
|
|
421
421
|
}
|
|
422
422
|
get shadowRoot() {
|
|
423
|
-
const t =
|
|
423
|
+
const t = d.get(this), e = R.get(t);
|
|
424
424
|
return e || null;
|
|
425
425
|
}
|
|
426
426
|
get validationMessage() {
|
|
427
|
-
const t =
|
|
427
|
+
const t = d.get(this);
|
|
428
428
|
return E(t, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), m.get(this);
|
|
429
429
|
}
|
|
430
430
|
get validity() {
|
|
431
|
-
const t =
|
|
432
|
-
return E(t, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."),
|
|
431
|
+
const t = d.get(this);
|
|
432
|
+
return E(t, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."), n.get(this);
|
|
433
433
|
}
|
|
434
434
|
get willValidate() {
|
|
435
|
-
const t =
|
|
435
|
+
const t = d.get(this);
|
|
436
436
|
return E(t, "Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element."), !(t.disabled || t.hasAttribute("disabled") || t.hasAttribute("readonly"));
|
|
437
437
|
}
|
|
438
438
|
}
|
|
@@ -476,7 +476,7 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
476
476
|
if (e.formAssociated) {
|
|
477
477
|
const i = e.prototype.connectedCallback;
|
|
478
478
|
e.prototype.connectedCallback = function() {
|
|
479
|
-
B.has(this) || (B.set(this, !0), this.hasAttribute("disabled") &&
|
|
479
|
+
B.has(this) || (B.set(this, !0), this.hasAttribute("disabled") && $(this, !0)), i != null && i.apply(this), Y(this);
|
|
480
480
|
};
|
|
481
481
|
}
|
|
482
482
|
r.call(this, t, e, o);
|
|
@@ -488,37 +488,58 @@ const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
488
488
|
throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.");
|
|
489
489
|
} else
|
|
490
490
|
return {};
|
|
491
|
-
if (
|
|
491
|
+
if (c.has(this))
|
|
492
492
|
throw new DOMException("DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");
|
|
493
493
|
return new et(this);
|
|
494
494
|
}), typeof Element < "u") {
|
|
495
495
|
let r = function(...e) {
|
|
496
496
|
const o = t.apply(this, e);
|
|
497
|
-
if (
|
|
497
|
+
if (R.set(this, o), S()) {
|
|
498
498
|
const i = new MutationObserver(P);
|
|
499
|
-
window.ShadyDOM ? i.observe(this,
|
|
499
|
+
window.ShadyDOM ? i.observe(this, _) : i.observe(o, _), b.set(this, i);
|
|
500
500
|
}
|
|
501
501
|
return o;
|
|
502
502
|
};
|
|
503
503
|
const t = Element.prototype.attachShadow;
|
|
504
504
|
Element.prototype.attachShadow = r;
|
|
505
505
|
}
|
|
506
|
-
S() && typeof document < "u" && new MutationObserver(P).observe(document.documentElement,
|
|
506
|
+
S() && typeof document < "u" && new MutationObserver(P).observe(document.documentElement, _), typeof HTMLFormElement < "u" && gt(), typeof window < "u" && !window.CustomStateSet && (window.CustomStateSet = V);
|
|
507
507
|
}
|
|
508
508
|
})();
|
|
509
|
-
var
|
|
510
|
-
for (var m =
|
|
511
|
-
(b =
|
|
512
|
-
return
|
|
509
|
+
var zt = Object.defineProperty, At = Object.getOwnPropertyDescriptor, g = (d, n, a, c) => {
|
|
510
|
+
for (var m = c > 1 ? void 0 : c ? At(n, a) : n, y = d.length - 1, b; y >= 0; y--)
|
|
511
|
+
(b = d[y]) && (m = (c ? b(n, a, m) : b(m)) || m);
|
|
512
|
+
return c && m && zt(n, a, m), m;
|
|
513
513
|
};
|
|
514
|
-
const
|
|
514
|
+
const C = "pie-button";
|
|
515
515
|
class h extends Et {
|
|
516
516
|
constructor() {
|
|
517
|
-
super(), this.size = "medium", this.type = "submit", this.variant = "primary", this.iconPlacement = "leading", this.disabled = !1, this.isLoading = !1, this.isFullWidth = !1, this.
|
|
517
|
+
super(), this.size = "medium", this.type = "submit", this.variant = "primary", this.iconPlacement = "leading", this.disabled = !1, this.isLoading = !1, this.isFullWidth = !1, this._handleFormKeyDown = (n) => {
|
|
518
|
+
if (!(n.key !== "Enter" || this.type !== "submit" || this.disabled)) {
|
|
519
|
+
if (n.target instanceof HTMLElement) {
|
|
520
|
+
const a = n.target.tagName.toLowerCase();
|
|
521
|
+
if (a === "button" || a === "pie-button")
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
n.preventDefault(), this._handleClick();
|
|
525
|
+
}
|
|
526
|
+
}, this._internals = this.attachInternals();
|
|
518
527
|
}
|
|
519
528
|
get form() {
|
|
520
529
|
return this._internals.form;
|
|
521
530
|
}
|
|
531
|
+
connectedCallback() {
|
|
532
|
+
var n;
|
|
533
|
+
super.connectedCallback(), this.type === "submit" && ((n = this.form) == null || n.addEventListener("keydown", this._handleFormKeyDown));
|
|
534
|
+
}
|
|
535
|
+
disconnectedCallback() {
|
|
536
|
+
var n;
|
|
537
|
+
super.disconnectedCallback(), this.type === "submit" && ((n = this.form) == null || n.removeEventListener("keydown", this._handleFormKeyDown));
|
|
538
|
+
}
|
|
539
|
+
updated(n) {
|
|
540
|
+
var a, c;
|
|
541
|
+
super.updated(n), n.has("type") && (this.type === "submit" ? (a = this.form) == null || a.addEventListener("keydown", this._handleFormKeyDown) : (c = this.form) == null || c.removeEventListener("keydown", this._handleFormKeyDown));
|
|
542
|
+
}
|
|
522
543
|
/**
|
|
523
544
|
* This method creates an invisible button of the same type as pie-button. It is then clicked, and immediately removed from the DOM.
|
|
524
545
|
* This is done so that we trigger native form actions, such as submit and reset in the browser. The performance impact of adding and removing a single button to the DOM
|
|
@@ -527,62 +548,62 @@ class h extends Et {
|
|
|
527
548
|
*
|
|
528
549
|
* TODO: if we need to repeat this logic elsewhere, then we should consider moving this code to a shared class or mixin.
|
|
529
550
|
*/
|
|
530
|
-
_simulateNativeButtonClick(
|
|
551
|
+
_simulateNativeButtonClick(n) {
|
|
531
552
|
if (!this.form)
|
|
532
553
|
return;
|
|
533
554
|
const a = document.createElement("button");
|
|
534
|
-
a.type =
|
|
555
|
+
a.type = n, a.style.position = "absolute", a.style.width = "1px", a.style.height = "1px", a.style.padding = "0", a.style.margin = "-1px", a.style.overflow = "hidden", a.style.border = "0", a.style.whiteSpace = "nowrap", n === "submit" && (this.name && (a.name = this.name), this.value && (a.value = this.value), this.formaction && a.setAttribute("formaction", this.formaction), this.formenctype && a.setAttribute("formenctype", this.formenctype), this.formmethod && a.setAttribute("formmethod", this.formmethod), this.formnovalidate && a.setAttribute("formnovalidate", "formnovalidate"), this.formtarget && a.setAttribute("formtarget", this.formtarget)), this.form.append(a), a.click(), a.remove();
|
|
535
556
|
}
|
|
536
557
|
_handleClick() {
|
|
537
558
|
!this.isLoading && this.form && (this.type === "submit" && (this.formnovalidate || this.form.reportValidity()) && this._simulateNativeButtonClick("submit"), this.type === "reset" && this._simulateNativeButtonClick("reset"));
|
|
538
559
|
}
|
|
539
560
|
render() {
|
|
540
561
|
const {
|
|
541
|
-
type:
|
|
562
|
+
type: n,
|
|
542
563
|
disabled: a,
|
|
543
|
-
isFullWidth:
|
|
564
|
+
isFullWidth: c,
|
|
544
565
|
variant: m,
|
|
545
566
|
size: y,
|
|
546
567
|
isLoading: b,
|
|
547
568
|
iconPlacement: p
|
|
548
569
|
} = this;
|
|
549
|
-
return
|
|
570
|
+
return O`
|
|
550
571
|
<button
|
|
551
572
|
@click=${this._handleClick}
|
|
552
573
|
class="o-btn"
|
|
553
|
-
type=${
|
|
574
|
+
type=${n}
|
|
554
575
|
variant=${m}
|
|
555
576
|
size=${y}
|
|
556
577
|
?disabled=${a}
|
|
557
|
-
?isFullWidth=${
|
|
578
|
+
?isFullWidth=${c}
|
|
558
579
|
?isLoading=${b}>
|
|
559
|
-
${p === "leading" ?
|
|
580
|
+
${p === "leading" ? O`<slot name="icon"></slot>` : ot}
|
|
560
581
|
<slot></slot>
|
|
561
|
-
${p === "trailing" ?
|
|
582
|
+
${p === "trailing" ? O`<slot name="icon"></slot>` : ot}
|
|
562
583
|
</button>`;
|
|
563
584
|
}
|
|
564
585
|
focus() {
|
|
565
|
-
var
|
|
566
|
-
(a = (
|
|
586
|
+
var n, a;
|
|
587
|
+
(a = (n = this.shadowRoot) == null ? void 0 : n.querySelector("button")) == null || a.focus();
|
|
567
588
|
}
|
|
568
589
|
}
|
|
569
590
|
h.formAssociated = !0;
|
|
570
|
-
h.styles = wt(
|
|
591
|
+
h.styles = wt(Ft);
|
|
571
592
|
g([
|
|
572
593
|
f(),
|
|
573
|
-
N(
|
|
594
|
+
N(C, kt, "medium")
|
|
574
595
|
], h.prototype, "size", 2);
|
|
575
596
|
g([
|
|
576
597
|
f(),
|
|
577
|
-
N(
|
|
598
|
+
N(C, Mt, "submit")
|
|
578
599
|
], h.prototype, "type", 2);
|
|
579
600
|
g([
|
|
580
601
|
f(),
|
|
581
|
-
N(
|
|
602
|
+
N(C, Ct, "primary")
|
|
582
603
|
], h.prototype, "variant", 2);
|
|
583
604
|
g([
|
|
584
605
|
f({ type: String }),
|
|
585
|
-
N(
|
|
606
|
+
N(C, Lt, "leading")
|
|
586
607
|
], h.prototype, "iconPlacement", 2);
|
|
587
608
|
g([
|
|
588
609
|
f({ type: Boolean })
|
|
@@ -614,14 +635,14 @@ g([
|
|
|
614
635
|
g([
|
|
615
636
|
f()
|
|
616
637
|
], h.prototype, "formtarget", 2);
|
|
617
|
-
xt(
|
|
638
|
+
xt(C, h);
|
|
618
639
|
export {
|
|
619
640
|
h as PieButton,
|
|
620
641
|
St as formEncodingtypes,
|
|
621
642
|
Vt as formMethodTypes,
|
|
622
643
|
Nt as formTargetTypes,
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
644
|
+
Lt as iconPlacements,
|
|
645
|
+
kt as sizes,
|
|
646
|
+
Mt as types,
|
|
647
|
+
Ct as variants
|
|
627
648
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSResult } from 'lit';
|
|
2
2
|
import type { LitElement } from 'lit';
|
|
3
|
+
import type { PropertyValues } from 'lit';
|
|
3
4
|
import type { ReactWebComponent } from '@lit-labs/react';
|
|
4
5
|
import type { TemplateResult } from 'lit-html';
|
|
5
6
|
|
|
@@ -92,6 +93,9 @@ declare class PieButton_2 extends LitElement implements ButtonProps {
|
|
|
92
93
|
private readonly _internals;
|
|
93
94
|
get form(): HTMLFormElement | null;
|
|
94
95
|
constructor();
|
|
96
|
+
connectedCallback(): void;
|
|
97
|
+
disconnectedCallback(): void;
|
|
98
|
+
updated(changedProperties: PropertyValues<this>): void;
|
|
95
99
|
size: ButtonProps['size'];
|
|
96
100
|
type: ButtonProps['type'];
|
|
97
101
|
variant: ButtonProps['variant'];
|
|
@@ -116,6 +120,7 @@ declare class PieButton_2 extends LitElement implements ButtonProps {
|
|
|
116
120
|
*/
|
|
117
121
|
private _simulateNativeButtonClick;
|
|
118
122
|
private _handleClick;
|
|
123
|
+
private _handleFormKeyDown;
|
|
119
124
|
render(): TemplateResult<1>;
|
|
120
125
|
focus(): void;
|
|
121
126
|
static styles: CSSResult;
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { PieButton as
|
|
3
|
-
import { formEncodingtypes as j, formMethodTypes as k, formTargetTypes as
|
|
1
|
+
import * as w from "react";
|
|
2
|
+
import { PieButton as E } from "./index.js";
|
|
3
|
+
import { formEncodingtypes as j, formMethodTypes as k, formTargetTypes as A, iconPlacements as D, sizes as G, types as H, variants as O } from "./index.js";
|
|
4
4
|
import "lit";
|
|
5
5
|
import "lit/decorators.js";
|
|
6
6
|
/**
|
|
@@ -8,59 +8,60 @@ import "lit/decorators.js";
|
|
|
8
8
|
* Copyright 2018 Google LLC
|
|
9
9
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
10
10
|
*/
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
})(
|
|
11
|
+
const b = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), g = /* @__PURE__ */ new WeakMap(), M = (t, o, m, p, d) => {
|
|
12
|
+
const i = d == null ? void 0 : d[o];
|
|
13
|
+
i === void 0 || m === p ? m == null && o in HTMLElement.prototype ? t.removeAttribute(o) : t[o] = m : ((r, n, u) => {
|
|
14
|
+
let a = g.get(r);
|
|
15
|
+
a === void 0 && g.set(r, a = /* @__PURE__ */ new Map());
|
|
16
|
+
let l = a.get(n);
|
|
17
|
+
u !== void 0 ? l === void 0 ? (a.set(n, l = { handleEvent: u }), r.addEventListener(n, l)) : l.handleEvent = u : l !== void 0 && (a.delete(n), r.removeEventListener(n, l));
|
|
18
|
+
})(t, i, m);
|
|
19
|
+
}, P = (t, o) => {
|
|
20
|
+
typeof t == "function" ? t(o) : t.current = o;
|
|
19
21
|
};
|
|
20
|
-
function B(
|
|
21
|
-
let
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
24
|
-
({ tagName:
|
|
22
|
+
function B(t = window.React, o, m, p, d) {
|
|
23
|
+
let i, r, n;
|
|
24
|
+
if (o === void 0) {
|
|
25
|
+
const c = t;
|
|
26
|
+
({ tagName: r, elementClass: n, events: p, displayName: d } = c), i = c.react;
|
|
25
27
|
} else
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
class
|
|
28
|
+
i = t, n = m, r = o;
|
|
29
|
+
const u = i.Component, a = i.createElement, l = new Set(Object.keys(p ?? {}));
|
|
30
|
+
class f extends u {
|
|
29
31
|
constructor() {
|
|
30
32
|
super(...arguments), this.o = null;
|
|
31
33
|
}
|
|
32
34
|
t(e) {
|
|
33
35
|
if (this.o !== null)
|
|
34
|
-
for (const
|
|
35
|
-
|
|
36
|
+
for (const h in this.i)
|
|
37
|
+
M(this.o, h, this.props[h], e ? e[h] : void 0, p);
|
|
36
38
|
}
|
|
37
39
|
componentDidMount() {
|
|
38
|
-
|
|
40
|
+
var e;
|
|
41
|
+
this.t(), (e = this.o) === null || e === void 0 || e.removeAttribute("defer-hydration");
|
|
39
42
|
}
|
|
40
43
|
componentDidUpdate(e) {
|
|
41
44
|
this.t(e);
|
|
42
45
|
}
|
|
43
46
|
render() {
|
|
44
|
-
const { _$Gl: e, ...
|
|
45
|
-
this.h !== e && (this.u = (
|
|
46
|
-
e !== null && (
|
|
47
|
-
typeof c == "function" ? c(g) : c.current = g;
|
|
48
|
-
})(e, n), this.o = n, this.h = e;
|
|
47
|
+
const { _$Gl: e, ...h } = this.props;
|
|
48
|
+
this.h !== e && (this.u = (s) => {
|
|
49
|
+
e !== null && P(e, s), this.o = s, this.h = e;
|
|
49
50
|
}), this.i = {};
|
|
50
|
-
const
|
|
51
|
-
for (const [
|
|
52
|
-
|
|
53
|
-
return
|
|
51
|
+
const v = { ref: this.u };
|
|
52
|
+
for (const [s, y] of Object.entries(h))
|
|
53
|
+
b.has(s) ? v[s === "className" ? "class" : s] = y : l.has(s) || s in n.prototype ? this.i[s] = y : v[s] = y;
|
|
54
|
+
return v.suppressHydrationWarning = !0, a(r, v);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
const N =
|
|
58
|
-
return N.displayName =
|
|
57
|
+
f.displayName = d ?? n.name;
|
|
58
|
+
const N = i.forwardRef((c, e) => a(f, { ...c, _$Gl: e }, c == null ? void 0 : c.children));
|
|
59
|
+
return N.displayName = f.displayName, N;
|
|
59
60
|
}
|
|
60
61
|
const L = B({
|
|
61
62
|
displayName: "PieButton",
|
|
62
|
-
elementClass:
|
|
63
|
-
react:
|
|
63
|
+
elementClass: E,
|
|
64
|
+
react: w,
|
|
64
65
|
tagName: "pie-button",
|
|
65
66
|
events: {}
|
|
66
67
|
});
|
|
@@ -68,9 +69,9 @@ export {
|
|
|
68
69
|
L as PieButton,
|
|
69
70
|
j as formEncodingtypes,
|
|
70
71
|
k as formMethodTypes,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
A as formTargetTypes,
|
|
73
|
+
D as iconPlacements,
|
|
74
|
+
G as sizes,
|
|
75
|
+
H as types,
|
|
76
|
+
O as variants
|
|
76
77
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-button",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "PIE design system button built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@justeat/pie-design-tokens": "5.8.2",
|
|
32
32
|
"@justeattakeaway/pie-components-config": "0.4.0",
|
|
33
|
-
"@justeattakeaway/pie-css": "0.
|
|
33
|
+
"@justeattakeaway/pie-css": "0.7.0",
|
|
34
34
|
"@justeattakeaway/pie-webc-core": "0.11.0"
|
|
35
35
|
},
|
|
36
36
|
"volta": {
|
package/src/button.scss
CHANGED
|
@@ -6,46 +6,6 @@
|
|
|
6
6
|
box-sizing: border-box;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Defines button interactive states for hover, active and loading.
|
|
11
|
-
* $bg-color: design token name to be used for the states
|
|
12
|
-
* $mode: 'default': apply the default lighten/darken to the color via hsl
|
|
13
|
-
* 'transparent': uses hsla syntax to make the color semi-opaque (used for ghost and outline button variants)
|
|
14
|
-
*/
|
|
15
|
-
@mixin button-interactive-states($bg-color, $mode: 'default') {
|
|
16
|
-
&:hover:not(:disabled) {
|
|
17
|
-
@if $mode == 'alt' {
|
|
18
|
-
--hover-modifier: calc(-1 * var(--dt-color-hover-02));
|
|
19
|
-
} @else {
|
|
20
|
-
--hover-modifier: calc(-1 * var(--dt-color-hover-01));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// for mode=transparent, use the hsla syntax to make the button background opaque by a set percentage
|
|
24
|
-
@if $mode == 'transparent' {
|
|
25
|
-
--hover-modifier: var(--dt-color-hover-01);
|
|
26
|
-
--btn-bg-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), var(#{$bg-color}-l), var(--hover-modifier));
|
|
27
|
-
} @else {
|
|
28
|
-
--btn-bg-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), calc(var(#{$bg-color}-l) + var(--hover-modifier)));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&:active:not(:disabled),
|
|
33
|
-
&[isLoading]:not(:disabled) {
|
|
34
|
-
@if $mode == 'alt' {
|
|
35
|
-
--active-modifier: calc(-1 * var(--dt-color-active-02));
|
|
36
|
-
} @else {
|
|
37
|
-
--active-modifier: calc(-1 * var(--dt-color-active-01));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@if $mode == 'transparent' {
|
|
41
|
-
--active-modifier: var(--dt-color-active-01);
|
|
42
|
-
--btn-bg-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), var(#{$bg-color}-l), var(--active-modifier));
|
|
43
|
-
} @else {
|
|
44
|
-
--btn-bg-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), calc(var(#{$bg-color}-l) + var(--active-modifier)));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
9
|
/**
|
|
50
10
|
* Shorthand mixin for updating the HSL custom properties for the loading spinner.
|
|
51
11
|
* Takes in the name of the color to be split into its HSL components.
|
|
@@ -142,7 +102,7 @@
|
|
|
142
102
|
|
|
143
103
|
// Variant
|
|
144
104
|
&[variant='primary'] {
|
|
145
|
-
@include button-interactive-states('--dt-color-interactive-brand');
|
|
105
|
+
@include p.button-interactive-states('--dt-color-interactive-brand');
|
|
146
106
|
|
|
147
107
|
&[size='xsmall'],
|
|
148
108
|
&[size='small-productive'] {
|
|
@@ -152,7 +112,7 @@
|
|
|
152
112
|
**/
|
|
153
113
|
--btn-bg-color: var(--dt-color-interactive-primary);
|
|
154
114
|
|
|
155
|
-
@include button-interactive-states('--dt-color-interactive-primary', 'alt');
|
|
115
|
+
@include p.button-interactive-states('--dt-color-interactive-primary', 'alt');
|
|
156
116
|
}
|
|
157
117
|
}
|
|
158
118
|
|
|
@@ -160,7 +120,7 @@
|
|
|
160
120
|
--btn-bg-color: var(--dt-color-interactive-secondary);
|
|
161
121
|
--btn-text-color: var(--dt-color-content-interactive-secondary);
|
|
162
122
|
|
|
163
|
-
@include button-interactive-states('--dt-color-interactive-secondary');
|
|
123
|
+
@include p.button-interactive-states('--dt-color-interactive-secondary');
|
|
164
124
|
@include spinner-base-colors('--dt-color-content-interactive-secondary');
|
|
165
125
|
}
|
|
166
126
|
|
|
@@ -172,7 +132,7 @@
|
|
|
172
132
|
|
|
173
133
|
// use black as the background color for hover and inverse,
|
|
174
134
|
// as this variant uses a shade of transparent black showing through the container background
|
|
175
|
-
@include button-interactive-states('--dt-color-black', 'transparent');
|
|
135
|
+
@include p.button-interactive-states('--dt-color-black', 'transparent');
|
|
176
136
|
@include spinner-base-colors('--dt-color-content-interactive-secondary');
|
|
177
137
|
}
|
|
178
138
|
|
|
@@ -182,7 +142,7 @@
|
|
|
182
142
|
|
|
183
143
|
// use black as the background color for hover and inverse,
|
|
184
144
|
// as this variant uses a shade of transparent black showing through the container background
|
|
185
|
-
@include button-interactive-states('--dt-color-black', 'transparent');
|
|
145
|
+
@include p.button-interactive-states('--dt-color-black', 'transparent');
|
|
186
146
|
@include spinner-base-colors('--dt-color-content-interactive-secondary');
|
|
187
147
|
}
|
|
188
148
|
|
|
@@ -190,7 +150,7 @@
|
|
|
190
150
|
--btn-bg-color: var(--dt-color-interactive-inverse);
|
|
191
151
|
--btn-text-color: var(--dt-color-content-interactive-secondary);
|
|
192
152
|
|
|
193
|
-
@include button-interactive-states('--dt-color-interactive-inverse');
|
|
153
|
+
@include p.button-interactive-states('--dt-color-interactive-inverse');
|
|
194
154
|
@include spinner-base-colors('--dt-color-content-interactive-secondary');
|
|
195
155
|
}
|
|
196
156
|
|
|
@@ -201,7 +161,7 @@
|
|
|
201
161
|
|
|
202
162
|
// use white as the background color for hover and inverse,
|
|
203
163
|
// as these variants use a shade of transparent white showing through the container background
|
|
204
|
-
@include button-interactive-states('--dt-color-container-default', 'transparent');
|
|
164
|
+
@include p.button-interactive-states('--dt-color-container-default', 'transparent');
|
|
205
165
|
}
|
|
206
166
|
|
|
207
167
|
&[variant='outline-inverse'] {
|
|
@@ -211,7 +171,7 @@
|
|
|
211
171
|
&[variant='destructive'] {
|
|
212
172
|
--btn-bg-color: var(--dt-color-support-error);
|
|
213
173
|
|
|
214
|
-
@include button-interactive-states('--dt-color-support-error');
|
|
174
|
+
@include p.button-interactive-states('--dt-color-support-error');
|
|
215
175
|
}
|
|
216
176
|
|
|
217
177
|
&[variant='destructive-ghost'] {
|
|
@@ -220,7 +180,7 @@
|
|
|
220
180
|
|
|
221
181
|
// use black as the background color for hover and inverse,
|
|
222
182
|
// as this variant uses a shade of transparent black showing through the container background
|
|
223
|
-
@include button-interactive-states('--dt-color-black', 'transparent');
|
|
183
|
+
@include p.button-interactive-states('--dt-color-black', 'transparent');
|
|
224
184
|
@include spinner-base-colors('--dt-color-content-interactive-secondary');
|
|
225
185
|
}
|
|
226
186
|
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LitElement, html, unsafeCSS, nothing,
|
|
2
|
+
LitElement, html, unsafeCSS, nothing, PropertyValues,
|
|
3
3
|
} from 'lit';
|
|
4
4
|
import { property } from 'lit/decorators.js';
|
|
5
5
|
import { validPropertyValues, defineCustomElement } from '@justeattakeaway/pie-webc-core';
|
|
@@ -34,6 +34,35 @@ export class PieButton extends LitElement implements ButtonProps {
|
|
|
34
34
|
this._internals = this.attachInternals();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
connectedCallback () {
|
|
38
|
+
super.connectedCallback();
|
|
39
|
+
|
|
40
|
+
if (this.type === 'submit') {
|
|
41
|
+
this.form?.addEventListener('keydown', this._handleFormKeyDown);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
disconnectedCallback () {
|
|
46
|
+
super.disconnectedCallback();
|
|
47
|
+
|
|
48
|
+
if (this.type === 'submit') {
|
|
49
|
+
this.form?.removeEventListener('keydown', this._handleFormKeyDown);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
updated (changedProperties: PropertyValues<this>): void {
|
|
54
|
+
super.updated(changedProperties);
|
|
55
|
+
|
|
56
|
+
if (changedProperties.has('type')) {
|
|
57
|
+
// If the new type is "submit", add the keydown event listener
|
|
58
|
+
if (this.type === 'submit') {
|
|
59
|
+
this.form?.addEventListener('keydown', this._handleFormKeyDown);
|
|
60
|
+
} else {
|
|
61
|
+
this.form?.removeEventListener('keydown', this._handleFormKeyDown);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
37
66
|
@property()
|
|
38
67
|
@validPropertyValues(componentSelector, sizes, 'medium')
|
|
39
68
|
public size: ButtonProps['size'] = 'medium';
|
|
@@ -148,6 +177,25 @@ export class PieButton extends LitElement implements ButtonProps {
|
|
|
148
177
|
}
|
|
149
178
|
}
|
|
150
179
|
|
|
180
|
+
// This allows a user to press enter anywhere inside the form and trigger a form submission
|
|
181
|
+
private _handleFormKeyDown = (event: KeyboardEvent) => {
|
|
182
|
+
if (event.key !== 'Enter' || this.type !== 'submit' || this.disabled) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (event.target instanceof HTMLElement) {
|
|
187
|
+
const targetTagName = event.target.tagName.toLowerCase();
|
|
188
|
+
|
|
189
|
+
// We want to ignore the enter key if the user is on a button or another pie-button
|
|
190
|
+
if (targetTagName === 'button' || targetTagName === 'pie-button') {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
this._handleClick();
|
|
197
|
+
};
|
|
198
|
+
|
|
151
199
|
render () {
|
|
152
200
|
const {
|
|
153
201
|
type,
|