@justeattakeaway/pie-form-label 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/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright (c) Just Eat Takeaway.com
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,106 @@
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-form-label">
7
+ <img alt="GitHub Workflow Status" src="https://img.shields.io/npm/v/@justeattakeaway/pie-form-label.svg">
8
+ </a>
9
+ </p>
10
+
11
+ # Table of Contents
12
+
13
+ 1. [Introduction](#pie-form-label)
14
+ 2. [Local Development](#local-development)
15
+ 3. [Importing the component](#importing-the-component)
16
+ 4. [Props](#props)
17
+ 5. [Testing](#testing)
18
+
19
+ # pie-form-label
20
+
21
+ `pie-form-label` is a Web Component built using the Lit library.
22
+
23
+ This component can be easily integrated into various frontend frameworks and customized through a set of properties.
24
+
25
+ ## Local development
26
+
27
+ Install the dependencies. Note that this, and the following commands below, should be run from the **root of the monorepo**:
28
+
29
+ ```bash
30
+ yarn
31
+ ```
32
+
33
+ To build the `pie-form-label` package, run the following command:
34
+
35
+ ```bash
36
+ yarn build --filter=pie-form-label
37
+ ```
38
+
39
+ 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:
40
+
41
+ ```bash
42
+ yarn watch --filter=pie-form-label
43
+
44
+ # in a separate terminal tab, run
45
+ yarn dev --filter=pie-storybook
46
+ ```
47
+
48
+ ### Importing the component
49
+
50
+ ```js
51
+ // default
52
+ import { PieFormLabel } from '@justeattakeaway/pie-form-label';
53
+
54
+ // react
55
+ import { PieFormLabel } from '@justeattakeaway/pie-form-label/dist/react';
56
+ ```
57
+
58
+ ## Props
59
+
60
+ | Property | Type | Default | Description |
61
+ |---|---|---|---|
62
+ | - | - | - | - |
63
+
64
+ In your markup or JSX, you can then use these to set the properties for the `pie-form-label` component:
65
+
66
+ ```html
67
+ <!-- Native HTML -->
68
+ <pie-form-label></pie-form-label>
69
+
70
+ <!-- JSX -->
71
+ <PieFormLabel></PieFormLabel>
72
+ ```
73
+
74
+ ## Testing
75
+
76
+ ### Browser tests
77
+
78
+ To run the browser tests, run the following command from the root of the monorepo:
79
+
80
+ ```bash
81
+ yarn test:browsers --filter=pie-form-label
82
+ ```
83
+
84
+ ### Visual tests
85
+
86
+ To run the visual regression tests, run the following command from the root of the monorepo:
87
+
88
+ ```bash
89
+ yarn test:visual --filter=pie-form-label
90
+ ```
91
+
92
+ 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.
93
+
94
+ #### Setup via bash
95
+
96
+ ```bash
97
+ export PERCY_TOKEN_PIE_FORM_LABEL=abcde
98
+ ```
99
+
100
+ #### Setup via package.json
101
+
102
+ Under scripts `test:visual` replace the environment variable with the below:
103
+
104
+ ```bash
105
+ PERCY_TOKEN_PIE_FORM_LABEL=abcde
106
+ ```
@@ -0,0 +1,9 @@
1
+ declare module '*.scss' {
2
+ const content: Record<string, string>;
3
+ export default content;
4
+ }
5
+
6
+ declare module '*.scss?inline' {
7
+ const content: Record<string, string>;
8
+ export default content;
9
+ }
@@ -0,0 +1,13 @@
1
+ import type { CSSResult } from 'lit';
2
+ import type { LitElement } from 'lit';
3
+ import type { TemplateResult } from 'lit-html';
4
+
5
+ export declare interface FormLabelProps {
6
+ }
7
+
8
+ export declare class PieFormLabel extends LitElement implements FormLabelProps {
9
+ render(): TemplateResult<1>;
10
+ static styles: CSSResult;
11
+ }
12
+
13
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import { unsafeCSS as t, LitElement as l, html as o } from "lit";
2
+ const s = "", r = "pie-form-label";
3
+ class e extends l {
4
+ render() {
5
+ return o`<h1 data-test-id="pie-form-label">Hello world!</h1>`;
6
+ }
7
+ }
8
+ e.styles = t(s);
9
+ customElements.define(r, e);
10
+ export {
11
+ e as PieFormLabel
12
+ };
@@ -0,0 +1,16 @@
1
+ import type { CSSResult } from 'lit';
2
+ import type { LitElement } from 'lit';
3
+ import type { ReactWebComponent } from '@lit-labs/react';
4
+ import type { TemplateResult } from 'lit-html';
5
+
6
+ export declare interface FormLabelProps {
7
+ }
8
+
9
+ export declare const PieFormLabel: ReactWebComponent<PieFormLabel_2, {}>;
10
+
11
+ declare class PieFormLabel_2 extends LitElement implements FormLabelProps {
12
+ render(): TemplateResult<1>;
13
+ static styles: CSSResult;
14
+ }
15
+
16
+ export { }
package/dist/react.js ADDED
@@ -0,0 +1,67 @@
1
+ import * as L from "react";
2
+ import { PieFormLabel as E } from "./index.js";
3
+ import "lit";
4
+ /**
5
+ * @license
6
+ * Copyright 2018 Google LLC
7
+ * SPDX-License-Identifier: BSD-3-Clause
8
+ */
9
+ const g = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), w = /* @__PURE__ */ new WeakMap(), F = (m, a, d, p, h) => {
10
+ const s = h == null ? void 0 : h[a];
11
+ s === void 0 || d === p ? d == null && a in HTMLElement.prototype ? m.removeAttribute(a) : m[a] = d : ((n, t, u) => {
12
+ let o = w.get(n);
13
+ o === void 0 && w.set(n, o = /* @__PURE__ */ new Map());
14
+ let l = o.get(t);
15
+ u !== void 0 ? l === void 0 ? (o.set(t, l = { handleEvent: u }), n.addEventListener(t, l)) : l.handleEvent = u : l !== void 0 && (o.delete(t), n.removeEventListener(t, l));
16
+ })(m, s, d);
17
+ };
18
+ function M(m = window.React, a, d, p, h) {
19
+ let s, n, t;
20
+ if (a === void 0) {
21
+ const r = m;
22
+ ({ tagName: n, elementClass: t, events: p, displayName: h } = r), s = r.react;
23
+ } else
24
+ s = m, t = d, n = a;
25
+ const u = s.Component, o = s.createElement, l = new Set(Object.keys(p ?? {}));
26
+ class f extends u {
27
+ constructor() {
28
+ super(...arguments), this.o = null;
29
+ }
30
+ t(e) {
31
+ if (this.o !== null)
32
+ for (const v in this.i)
33
+ F(this.o, v, this.props[v], e ? e[v] : void 0, p);
34
+ }
35
+ componentDidMount() {
36
+ this.t();
37
+ }
38
+ componentDidUpdate(e) {
39
+ this.t(e);
40
+ }
41
+ render() {
42
+ const { _$Gl: e, ...v } = this.props;
43
+ this.h !== e && (this.u = (i) => {
44
+ e !== null && ((c, b) => {
45
+ typeof c == "function" ? c(b) : c.current = b;
46
+ })(e, i), this.o = i, this.h = e;
47
+ }), this.i = {};
48
+ const y = { ref: this.u };
49
+ for (const [i, c] of Object.entries(v))
50
+ g.has(i) ? y[i === "className" ? "class" : i] = c : l.has(i) || i in t.prototype ? this.i[i] = c : y[i] = c;
51
+ return o(n, y);
52
+ }
53
+ }
54
+ f.displayName = h ?? t.name;
55
+ const N = s.forwardRef((r, e) => o(f, { ...r, _$Gl: e }, r == null ? void 0 : r.children));
56
+ return N.displayName = f.displayName, N;
57
+ }
58
+ const R = M({
59
+ displayName: "PieFormLabel",
60
+ elementClass: E,
61
+ react: L,
62
+ tagName: "pie-form-label",
63
+ events: {}
64
+ });
65
+ export {
66
+ R as PieFormLabel
67
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@justeattakeaway/pie-form-label",
3
+ "description": "PIE Design System Form Label 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
+ "src",
11
+ "dist",
12
+ "**/*.d.ts"
13
+ ],
14
+ "scripts": {
15
+ "build": "yarn build:wrapper pie-form-label && run -T vite build",
16
+ "lint:scripts": "run -T eslint .",
17
+ "lint:scripts:fix": "yarn lint:scripts --fix",
18
+ "lint:style": "run -T stylelint ./src/**/*.{css,scss}",
19
+ "lint:style:fix": "yarn lint:style --fix",
20
+ "watch": "run -T vite build --watch",
21
+ "test": "echo \"Error: no test specified\" && exit 0",
22
+ "test:ci": "yarn test",
23
+ "test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
24
+ "test:browsers:ci": "yarn test:browsers",
25
+ "test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_FORM_LABEL} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
26
+ "test:visual:ci": "yarn test:visual"
27
+ },
28
+ "author": "JustEatTakeaway.com - Design System Web Team",
29
+ "license": "Apache-2.0",
30
+ "devDependencies": {
31
+ "@justeattakeaway/pie-components-config": "workspace:*"
32
+ },
33
+ "dependencies": {
34
+ "@justeattakeaway/pie-webc-core": "workspace:*"
35
+ },
36
+ "volta": {
37
+ "extends": "../../../package.json"
38
+ }
39
+ }
package/src/defs.ts ADDED
@@ -0,0 +1,3 @@
1
+ // TODO - please remove the eslint disable comment below when you add props to this interface
2
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
3
+ export interface FormLabelProps {}
@@ -0,0 +1 @@
1
+ @use '@justeattakeaway/pie-css/scss' as p;
package/src/index.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { LitElement, html, unsafeCSS } from 'lit';
2
+
3
+ import styles from './form-label.scss?inline';
4
+ import { FormLabelProps } from './defs';
5
+
6
+ // Valid values available to consumers
7
+ export * from './defs';
8
+
9
+ const componentSelector = 'pie-form-label';
10
+
11
+ export class PieFormLabel extends LitElement implements FormLabelProps {
12
+ render () {
13
+ return html`<h1 data-test-id="pie-form-label">Hello world!</h1>`;
14
+ }
15
+
16
+ // Renders a `CSSResult` generated from SCSS by Vite
17
+ static styles = unsafeCSS(styles);
18
+ }
19
+
20
+ customElements.define(componentSelector, PieFormLabel);
21
+
22
+ declare global {
23
+ interface HTMLElementTagNameMap {
24
+ [componentSelector]: PieFormLabel;
25
+ }
26
+ }