@justeattakeaway/pie-toast-provider 0.0.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 +91 -0
- package/custom-elements.json +60 -0
- package/declaration.d.ts +9 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +13 -0
- package/dist/react.d.ts +25 -0
- package/dist/react.js +13 -0
- package/package.json +53 -0
- package/src/defs-react.ts +8 -0
- package/src/defs.ts +3 -0
- package/src/index.ts +30 -0
- package/src/react.ts +19 -0
- package/src/toast-provider.scss +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img align="center" src="../../../readme_image.png" height="200" alt="">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/@justeattakeaway/pie-toast-provider">
|
|
7
|
+
<img alt="GitHub Workflow Status" src="https://img.shields.io/npm/v/@justeattakeaway/pie-toast-provider.svg">
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
# Table of Contents
|
|
12
|
+
|
|
13
|
+
1. [Introduction](#pie-toast-provider)
|
|
14
|
+
2. [Installation](#installation)
|
|
15
|
+
3. [Importing the component](#importing-the-component)
|
|
16
|
+
4. [Peer Dependencies](#peer-dependencies)
|
|
17
|
+
5. [Props](#props)
|
|
18
|
+
6. [Contributing](#contributing)
|
|
19
|
+
|
|
20
|
+
## pie-toast-provider
|
|
21
|
+
|
|
22
|
+
`pie-toast-provider` is a Web Component built using the Lit library.
|
|
23
|
+
|
|
24
|
+
This component can be easily integrated into various frontend frameworks and customized through a set of properties.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
To install `pie-toast-provider` in your application, run the following on your command line:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# npm
|
|
33
|
+
$ npm i @justeattakeaway/pie-toast-provider
|
|
34
|
+
|
|
35
|
+
# yarn
|
|
36
|
+
$ yarn add @justeattakeaway/pie-toast-provider
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For full information on using PIE components as part of an application, check out the [Getting Started Guide](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components).
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Importing the component
|
|
43
|
+
|
|
44
|
+
#### JavaScript
|
|
45
|
+
```js
|
|
46
|
+
// Default – for Native JS Applications, Vue, Angular, Svelte, etc.
|
|
47
|
+
import { PieToastProvider } from '@justeattakeaway/pie-toast-provider';
|
|
48
|
+
|
|
49
|
+
// If you don't need to reference the imported object, you can simply
|
|
50
|
+
// import the module which registers the component as a custom element.
|
|
51
|
+
import '@justeattakeaway/pie-toast-provider';
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### React
|
|
55
|
+
```js
|
|
56
|
+
// React
|
|
57
|
+
// For React, you will need to import our React-specific component build
|
|
58
|
+
// which wraps the web component using @lit/react
|
|
59
|
+
import { PieToastProvider } from '@justeattakeaway/pie-toast-provider/dist/react';
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
> [!NOTE]
|
|
63
|
+
> When using the React version of the component, please make sure to also
|
|
64
|
+
> include React as a [peer dependency](#peer-dependencies) in your project.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## Peer Dependencies
|
|
68
|
+
|
|
69
|
+
> [!IMPORTANT]
|
|
70
|
+
> When using `pie-toast-provider`, you will also need to include a couple of dependencies to ensure the component renders as expected. See [the PIE Wiki](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components#expected-dependencies) for more information and how to include these in your application.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
## Props
|
|
74
|
+
|
|
75
|
+
| Property | Type | Default | Description |
|
|
76
|
+
|---|---|---|---|
|
|
77
|
+
| - | - | - | - |
|
|
78
|
+
|
|
79
|
+
In your markup or JSX, you can then use these to set the properties for the `pie-toast-provider` component:
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<!-- Native HTML -->
|
|
83
|
+
<pie-toast-provider></pie-toast-provider>
|
|
84
|
+
|
|
85
|
+
<!-- JSX -->
|
|
86
|
+
<PieToastProvider></PieToastProvider>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Contributing
|
|
90
|
+
|
|
91
|
+
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).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "src/defs-react.js",
|
|
8
|
+
"declarations": [],
|
|
9
|
+
"exports": []
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"kind": "javascript-module",
|
|
13
|
+
"path": "src/defs.js",
|
|
14
|
+
"declarations": [],
|
|
15
|
+
"exports": []
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"kind": "javascript-module",
|
|
19
|
+
"path": "src/index.js",
|
|
20
|
+
"declarations": [
|
|
21
|
+
{
|
|
22
|
+
"kind": "class",
|
|
23
|
+
"description": "",
|
|
24
|
+
"name": "PieToastProvider",
|
|
25
|
+
"members": [],
|
|
26
|
+
"mixins": [
|
|
27
|
+
{
|
|
28
|
+
"name": "RtlMixin",
|
|
29
|
+
"package": "@justeattakeaway/pie-webc-core"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"superclass": {
|
|
33
|
+
"name": "LitElement",
|
|
34
|
+
"package": "lit"
|
|
35
|
+
},
|
|
36
|
+
"tagName": "pie-toast-provider",
|
|
37
|
+
"customElement": true
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"exports": [
|
|
41
|
+
{
|
|
42
|
+
"kind": "js",
|
|
43
|
+
"name": "*",
|
|
44
|
+
"declaration": {
|
|
45
|
+
"name": "*",
|
|
46
|
+
"package": "./defs"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"kind": "js",
|
|
51
|
+
"name": "PieToastProvider",
|
|
52
|
+
"declaration": {
|
|
53
|
+
"name": "PieToastProvider",
|
|
54
|
+
"module": "src/index.js"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
package/declaration.d.ts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CSSResult } from 'lit';
|
|
2
|
+
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
3
|
+
import type { LitElement } from 'lit';
|
|
4
|
+
import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
5
|
+
import type { TemplateResult } from 'lit-html';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @tagname pie-toast-provider
|
|
9
|
+
*/
|
|
10
|
+
export declare class PieToastProvider extends PieToastProvider_base implements ToastProviderProps {
|
|
11
|
+
render(): TemplateResult<1>;
|
|
12
|
+
static styles: CSSResult;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare const PieToastProvider_base: GenericConstructor<RTLInterface> & typeof LitElement;
|
|
16
|
+
|
|
17
|
+
export declare interface ToastProviderProps {
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LitElement as o, html as s, unsafeCSS as n } from "lit";
|
|
2
|
+
import { RtlMixin as r, defineCustomElement as i } from "@justeattakeaway/pie-webc-core";
|
|
3
|
+
const l = "*,*:after,*:before{box-sizing:inherit}", m = "pie-toast-provider", e = class e extends r(o) {
|
|
4
|
+
render() {
|
|
5
|
+
return s`<h1 data-test-id="pie-toast-provider">Hello world!</h1>`;
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
e.styles = n(l);
|
|
9
|
+
let t = e;
|
|
10
|
+
i(m, t);
|
|
11
|
+
export {
|
|
12
|
+
t as PieToastProvider
|
|
13
|
+
};
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CSSResult } from 'lit';
|
|
2
|
+
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
3
|
+
import type { LitElement } from 'lit';
|
|
4
|
+
import * as React_2 from 'react';
|
|
5
|
+
import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
6
|
+
import type { TemplateResult } from 'lit-html';
|
|
7
|
+
|
|
8
|
+
export declare const PieToastProvider: React_2.ForwardRefExoticComponent<ToastProviderProps & React_2.RefAttributes<PieToastProvider_2> & ReactBaseType>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @tagname pie-toast-provider
|
|
12
|
+
*/
|
|
13
|
+
declare class PieToastProvider_2 extends PieToastProvider_base implements ToastProviderProps {
|
|
14
|
+
render(): TemplateResult<1>;
|
|
15
|
+
static styles: CSSResult;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare const PieToastProvider_base: GenericConstructor<RTLInterface> & typeof LitElement;
|
|
19
|
+
|
|
20
|
+
declare type ReactBaseType = React_2.HTMLAttributes<HTMLElement>;
|
|
21
|
+
|
|
22
|
+
export declare interface ToastProviderProps {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { }
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
import { createComponent as o } from "@lit/react";
|
|
3
|
+
import { PieToastProvider as r } from "./index.js";
|
|
4
|
+
const t = o({
|
|
5
|
+
displayName: "PieToastProvider",
|
|
6
|
+
elementClass: r,
|
|
7
|
+
react: e,
|
|
8
|
+
tagName: "pie-toast-provider",
|
|
9
|
+
events: {}
|
|
10
|
+
}), s = t;
|
|
11
|
+
export {
|
|
12
|
+
s as PieToastProvider
|
|
13
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@justeattakeaway/pie-toast-provider",
|
|
3
|
+
"description": "PIE Design System Toast Provider built using Web Components",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"custom-elements.json",
|
|
11
|
+
"src",
|
|
12
|
+
"dist",
|
|
13
|
+
"**/*.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"pieMetadata": {
|
|
16
|
+
"componentStatus": "alpha"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "run -T vite build",
|
|
20
|
+
"build:react-wrapper": "npx build-react-wrapper",
|
|
21
|
+
"create:manifest": "yarn cem analyze --litelement",
|
|
22
|
+
"lint:scripts": "run -T eslint .",
|
|
23
|
+
"lint:scripts:fix": "yarn lint:scripts --fix",
|
|
24
|
+
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
|
|
25
|
+
"lint:style:fix": "yarn lint:style --fix",
|
|
26
|
+
"watch": "run -T vite build --watch",
|
|
27
|
+
"test": "echo \"Error: no test specified\" && exit 0",
|
|
28
|
+
"test:ci": "yarn test",
|
|
29
|
+
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
|
|
30
|
+
"test:browsers:ci": "yarn test:browsers",
|
|
31
|
+
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_TOAST_PROVIDER} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
|
|
32
|
+
"test:visual:ci": "yarn test:visual",
|
|
33
|
+
"test:browsers-setup": "npx playwright-lit-setup"
|
|
34
|
+
},
|
|
35
|
+
"author": "Just Eat Takeaway.com - Design System Team",
|
|
36
|
+
"license": "Apache-2.0",
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
39
|
+
"@justeattakeaway/pie-components-config": "0.18.0",
|
|
40
|
+
"@justeattakeaway/pie-css": "0.13.1",
|
|
41
|
+
"cem-plugin-module-file-extensions": "0.0.5"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@justeattakeaway/pie-webc-core": "0.24.2"
|
|
45
|
+
},
|
|
46
|
+
"volta": {
|
|
47
|
+
"extends": "../../../package.json"
|
|
48
|
+
},
|
|
49
|
+
"customElements": "custom-elements.json",
|
|
50
|
+
"sideEffects": [
|
|
51
|
+
"dist/*.js"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* TODO: Verify if ReactBaseType can be set as a more specific React interface
|
|
4
|
+
* Use the React IntrinsicElements interface to find how to map standard HTML elements to existing React Interfaces
|
|
5
|
+
* Example: an HTML button maps to `React.ButtonHTMLAttributes<HTMLButtonElement>`
|
|
6
|
+
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0bb210867d16170c4a08d9ce5d132817651a0f80/types/react/index.d.ts#L2829
|
|
7
|
+
*/
|
|
8
|
+
export type ReactBaseType = React.HTMLAttributes<HTMLElement>
|
package/src/defs.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LitElement, html, unsafeCSS } from 'lit';
|
|
2
|
+
import { RtlMixin, defineCustomElement } from '@justeattakeaway/pie-webc-core';
|
|
3
|
+
|
|
4
|
+
import styles from './toast-provider.scss?inline';
|
|
5
|
+
import { type ToastProviderProps } from './defs';
|
|
6
|
+
|
|
7
|
+
// Valid values available to consumers
|
|
8
|
+
export * from './defs';
|
|
9
|
+
|
|
10
|
+
const componentSelector = 'pie-toast-provider';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @tagname pie-toast-provider
|
|
14
|
+
*/
|
|
15
|
+
export class PieToastProvider extends RtlMixin(LitElement) implements ToastProviderProps {
|
|
16
|
+
render () {
|
|
17
|
+
return html`<h1 data-test-id="pie-toast-provider">Hello world!</h1>`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Renders a `CSSResult` generated from SCSS by Vite
|
|
21
|
+
static styles = unsafeCSS(styles);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
defineCustomElement(componentSelector, PieToastProvider);
|
|
25
|
+
|
|
26
|
+
declare global {
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
[componentSelector]: PieToastProvider;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/react.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import { PieToastProvider as PieToastProviderLit } from './index';
|
|
4
|
+
import { type ToastProviderProps } from './defs';
|
|
5
|
+
|
|
6
|
+
export * from './defs';
|
|
7
|
+
|
|
8
|
+
const PieToastProviderReact = createComponent({
|
|
9
|
+
displayName: 'PieToastProvider',
|
|
10
|
+
elementClass: PieToastProviderLit,
|
|
11
|
+
react: React,
|
|
12
|
+
tagName: 'pie-toast-provider',
|
|
13
|
+
events: {},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
type ReactBaseType = React.HTMLAttributes<HTMLElement>
|
|
17
|
+
|
|
18
|
+
export const PieToastProvider = PieToastProviderReact as React.ForwardRefExoticComponent<React.PropsWithoutRef<ToastProviderProps>
|
|
19
|
+
& React.RefAttributes<PieToastProviderLit> & ReactBaseType>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@use '@justeattakeaway/pie-css/scss' as p;
|