@justeattakeaway/pie-divider 0.13.8 → 0.14.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/custom-elements.json +11 -13
- package/dist/index.d.ts +7 -2
- package/dist/index.js +54 -36
- package/dist/react.d.ts +7 -2
- package/dist/react.js +7 -6
- package/package.json +2 -2
- package/src/defs-react.ts +1 -1
- package/src/defs.ts +5 -0
- package/src/divider.scss +39 -15
- package/src/index.ts +37 -13
package/custom-elements.json
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"type": {
|
|
35
35
|
"text": "DefaultProps"
|
|
36
36
|
},
|
|
37
|
-
"default": "{\n variant: 'default',\n orientation: 'horizontal',\n}"
|
|
37
|
+
"default": "{\n variant: 'default',\n orientation: 'horizontal',\n label: '',\n}"
|
|
38
38
|
}
|
|
39
39
|
],
|
|
40
40
|
"exports": [
|
|
@@ -76,36 +76,34 @@
|
|
|
76
76
|
{
|
|
77
77
|
"kind": "field",
|
|
78
78
|
"name": "variant",
|
|
79
|
-
"type": {
|
|
80
|
-
"text": "DividerProps['variant']"
|
|
81
|
-
},
|
|
82
79
|
"privacy": "public",
|
|
83
80
|
"attribute": "variant"
|
|
84
81
|
},
|
|
85
82
|
{
|
|
86
83
|
"kind": "field",
|
|
87
84
|
"name": "orientation",
|
|
88
|
-
"type": {
|
|
89
|
-
"text": "DividerProps['orientation']"
|
|
90
|
-
},
|
|
91
85
|
"privacy": "public",
|
|
92
86
|
"attribute": "orientation"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"kind": "field",
|
|
90
|
+
"name": "label",
|
|
91
|
+
"privacy": "public",
|
|
92
|
+
"attribute": "label"
|
|
93
93
|
}
|
|
94
94
|
],
|
|
95
95
|
"attributes": [
|
|
96
96
|
{
|
|
97
97
|
"name": "variant",
|
|
98
|
-
"type": {
|
|
99
|
-
"text": "DividerProps['variant']"
|
|
100
|
-
},
|
|
101
98
|
"fieldName": "variant"
|
|
102
99
|
},
|
|
103
100
|
{
|
|
104
101
|
"name": "orientation",
|
|
105
|
-
"type": {
|
|
106
|
-
"text": "DividerProps['orientation']"
|
|
107
|
-
},
|
|
108
102
|
"fieldName": "orientation"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "label",
|
|
106
|
+
"fieldName": "label"
|
|
109
107
|
}
|
|
110
108
|
],
|
|
111
109
|
"superclass": {
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export declare interface DividerProps {
|
|
|
16
16
|
* What orientation the divider should be such as horizontal or vertical.
|
|
17
17
|
*/
|
|
18
18
|
orientation?: typeof orientations[number];
|
|
19
|
+
/**
|
|
20
|
+
* The label text for the divider.
|
|
21
|
+
*/
|
|
22
|
+
label?: string;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
export declare const orientations: readonly ["horizontal", "vertical"];
|
|
@@ -24,8 +28,9 @@ export declare const orientations: readonly ["horizontal", "vertical"];
|
|
|
24
28
|
* @tagname pie-divider
|
|
25
29
|
*/
|
|
26
30
|
export declare class PieDivider extends LitElement implements DividerProps {
|
|
27
|
-
variant:
|
|
28
|
-
orientation:
|
|
31
|
+
variant: "default" | "inverse";
|
|
32
|
+
orientation: "horizontal" | "vertical";
|
|
33
|
+
label: string;
|
|
29
34
|
render(): TemplateResult<1>;
|
|
30
35
|
static styles: CSSResult;
|
|
31
36
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,64 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
2
|
-
import { property as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { unsafeCSS as g, LitElement as m, html as c } from "lit";
|
|
2
|
+
import { property as s } from "lit/decorators.js";
|
|
3
|
+
import { classMap as p } from "lit/directives/class-map.js";
|
|
4
|
+
import { validPropertyValues as b, defineCustomElement as f } from "@justeattakeaway/pie-webc-core";
|
|
5
|
+
const u = `*,*:after,*:before{box-sizing:inherit}.c-divider{--divider-bg-color: var(--dt-color-divider-default);--divider-width: 100%;--divider-min-width: 16px;--divider-height: 1px;--divider-label-max-width: 90%;width:var(--divider-width)}.c-divider,.c-divider hr{margin:0;border:0;background-color:var(--divider-bg-color)}.c-divider:not(.c-divider--labelled){height:var(--divider-height)}.c-divider.c-divider--labelled{display:flex;align-items:center;text-align:center;gap:var(--dt-spacing-b);background-color:transparent}.c-divider.c-divider--labelled .c-divider-label{max-width:var(--divider-label-max-width);word-wrap:break-word}.c-divider.c-divider--labelled hr{flex-grow:1;height:var(--divider-height);min-width:var(--divider-min-width)}.c-divider.c-divider--labelled.c-divider--inverse{color:var(--dt-color-content-inverse)}.c-divider.c-divider--inverse{--divider-bg-color: var(--dt-color-divider-inverse)}.c-divider.c-divider--vertical{--divider-width: 1px;--divider-height: 100%}
|
|
6
|
+
`, w = ["default", "inverse"], x = ["horizontal", "vertical"], l = {
|
|
6
7
|
variant: "default",
|
|
7
|
-
orientation: "horizontal"
|
|
8
|
+
orientation: "horizontal",
|
|
9
|
+
label: ""
|
|
8
10
|
};
|
|
9
|
-
var
|
|
10
|
-
for (var i =
|
|
11
|
-
(v = a
|
|
12
|
-
return
|
|
11
|
+
var y = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, h = (n, d, t, r) => {
|
|
12
|
+
for (var i = r > 1 ? void 0 : r ? $(d, t) : d, a = n.length - 1, v; a >= 0; a--)
|
|
13
|
+
(v = n[a]) && (i = (r ? v(d, t, i) : v(i)) || i);
|
|
14
|
+
return r && i && y(d, t, i), i;
|
|
13
15
|
};
|
|
14
|
-
const
|
|
15
|
-
class
|
|
16
|
+
const e = "pie-divider";
|
|
17
|
+
class o extends m {
|
|
16
18
|
constructor() {
|
|
17
|
-
super(...arguments), this.variant =
|
|
19
|
+
super(...arguments), this.variant = l.variant, this.orientation = l.orientation, this.label = l.label;
|
|
18
20
|
}
|
|
19
21
|
render() {
|
|
20
|
-
const { variant:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const { variant: d, orientation: t, label: r } = this, i = r.length > 0 && t === "horizontal", a = {
|
|
23
|
+
"c-divider": !0,
|
|
24
|
+
"c-divider--inverse": d === "inverse",
|
|
25
|
+
"c-divider--vertical": t === "vertical",
|
|
26
|
+
"c-divider--labelled": i
|
|
27
|
+
};
|
|
28
|
+
return c`
|
|
29
|
+
${i ? c`
|
|
30
|
+
<div
|
|
31
|
+
id="${e}"
|
|
32
|
+
data-test-id="${e}"
|
|
33
|
+
class="${p(a)}"
|
|
34
|
+
aria-labelledby="${e}-label">
|
|
35
|
+
<hr aria-hidden="true"/>
|
|
36
|
+
<span id="${e}-label" class="c-divider-label">${r}</span>
|
|
37
|
+
<hr aria-hidden="true"/>
|
|
38
|
+
</div>` : c`
|
|
39
|
+
<hr id="${e}"
|
|
40
|
+
data-test-id="${e}"
|
|
41
|
+
class="${p(a)}"
|
|
42
|
+
aria-hidden="true"
|
|
43
|
+
/>`}`;
|
|
29
44
|
}
|
|
30
45
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
],
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
],
|
|
40
|
-
|
|
46
|
+
o.styles = g(u);
|
|
47
|
+
h([
|
|
48
|
+
s({ type: String }),
|
|
49
|
+
b(e, w, l.variant)
|
|
50
|
+
], o.prototype, "variant", 2);
|
|
51
|
+
h([
|
|
52
|
+
s({ type: String }),
|
|
53
|
+
b(e, x, l.orientation)
|
|
54
|
+
], o.prototype, "orientation", 2);
|
|
55
|
+
h([
|
|
56
|
+
s({ type: String })
|
|
57
|
+
], o.prototype, "label", 2);
|
|
58
|
+
f(e, o);
|
|
41
59
|
export {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
o as PieDivider,
|
|
61
|
+
l as defaultProps,
|
|
62
|
+
x as orientations,
|
|
63
|
+
w as variants
|
|
46
64
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export declare interface DividerProps {
|
|
|
17
17
|
* What orientation the divider should be such as horizontal or vertical.
|
|
18
18
|
*/
|
|
19
19
|
orientation?: typeof orientations[number];
|
|
20
|
+
/**
|
|
21
|
+
* The label text for the divider.
|
|
22
|
+
*/
|
|
23
|
+
label?: string;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
export declare const orientations: readonly ["horizontal", "vertical"];
|
|
@@ -27,8 +31,9 @@ export declare const PieDivider: React_2.ForwardRefExoticComponent<DividerProps
|
|
|
27
31
|
* @tagname pie-divider
|
|
28
32
|
*/
|
|
29
33
|
declare class PieDivider_2 extends LitElement implements DividerProps {
|
|
30
|
-
variant:
|
|
31
|
-
orientation:
|
|
34
|
+
variant: "default" | "inverse";
|
|
35
|
+
orientation: "horizontal" | "vertical";
|
|
36
|
+
label: string;
|
|
32
37
|
render(): TemplateResult<1>;
|
|
33
38
|
static styles: CSSResult;
|
|
34
39
|
}
|
package/dist/react.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { createComponent as i } from "@lit/react";
|
|
3
3
|
import { PieDivider as r } from "./index.js";
|
|
4
|
-
import { defaultProps as
|
|
4
|
+
import { defaultProps as P, orientations as f, variants as D } from "./index.js";
|
|
5
5
|
import "lit";
|
|
6
6
|
import "lit/decorators.js";
|
|
7
|
+
import "lit/directives/class-map.js";
|
|
7
8
|
import "@justeattakeaway/pie-webc-core";
|
|
8
9
|
const t = i({
|
|
9
10
|
displayName: "PieDivider",
|
|
@@ -11,10 +12,10 @@ const t = i({
|
|
|
11
12
|
react: e,
|
|
12
13
|
tagName: "pie-divider",
|
|
13
14
|
events: {}
|
|
14
|
-
}),
|
|
15
|
+
}), n = t;
|
|
15
16
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
n as PieDivider,
|
|
18
|
+
P as defaultProps,
|
|
19
|
+
f as orientations,
|
|
20
|
+
D as variants
|
|
20
21
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-divider",
|
|
3
3
|
"description": "PIE Design System Divider built using Web Components",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
39
|
-
"@justeattakeaway/pie-components-config": "0.
|
|
39
|
+
"@justeattakeaway/pie-components-config": "0.18.0",
|
|
40
40
|
"@justeattakeaway/pie-css": "0.12.1",
|
|
41
41
|
"@justeattakeaway/pie-wrapper-react": "0.14.1",
|
|
42
42
|
"cem-plugin-module-file-extensions": "0.0.5"
|
package/src/defs-react.ts
CHANGED
package/src/defs.ts
CHANGED
|
@@ -12,6 +12,10 @@ export interface DividerProps {
|
|
|
12
12
|
* What orientation the divider should be such as horizontal or vertical.
|
|
13
13
|
*/
|
|
14
14
|
orientation?: typeof orientations[number];
|
|
15
|
+
/**
|
|
16
|
+
* The label text for the divider.
|
|
17
|
+
*/
|
|
18
|
+
label?: string;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export type DefaultProps = ComponentDefaultProps<DividerProps>;
|
|
@@ -19,4 +23,5 @@ export type DefaultProps = ComponentDefaultProps<DividerProps>;
|
|
|
19
23
|
export const defaultProps: DefaultProps = {
|
|
20
24
|
variant: 'default',
|
|
21
25
|
orientation: 'horizontal',
|
|
26
|
+
label: '',
|
|
22
27
|
};
|
package/src/divider.scss
CHANGED
|
@@ -1,30 +1,54 @@
|
|
|
1
1
|
@use '@justeattakeaway/pie-css/scss' as p;
|
|
2
2
|
|
|
3
3
|
.c-divider {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
--divider-bg-color: var(--dt-color-divider-default);
|
|
5
|
+
--divider-width: 100%;
|
|
6
|
+
--divider-min-width: 16px;
|
|
7
|
+
--divider-height: 1px;
|
|
8
|
+
--divider-label-max-width: 90%;
|
|
7
9
|
|
|
10
|
+
width: var(--divider-width);
|
|
11
|
+
|
|
12
|
+
&,
|
|
13
|
+
hr {
|
|
8
14
|
margin: 0;
|
|
9
15
|
border: 0;
|
|
10
|
-
width: var(--divider-width);
|
|
11
|
-
height: var(--divider-height);
|
|
12
16
|
background-color: var(--divider-bg-color);
|
|
17
|
+
}
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
&:not(.c-divider--labelled) {
|
|
20
|
+
height: var(--divider-height);
|
|
21
|
+
}
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
&.c-divider--labelled {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
text-align: center;
|
|
27
|
+
gap: var(--dt-spacing-b);
|
|
28
|
+
background-color: transparent;
|
|
29
|
+
|
|
30
|
+
.c-divider-label {
|
|
31
|
+
max-width: var(--divider-label-max-width);
|
|
32
|
+
word-wrap: break-word;
|
|
20
33
|
}
|
|
21
34
|
|
|
22
|
-
|
|
23
|
-
|
|
35
|
+
hr {
|
|
36
|
+
flex-grow: 1;
|
|
37
|
+
height: var(--divider-height);
|
|
38
|
+
min-width: var(--divider-min-width);
|
|
24
39
|
}
|
|
25
40
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
--divider-height: 100%;
|
|
41
|
+
&.c-divider--inverse {
|
|
42
|
+
color: var(--dt-color-content-inverse);
|
|
29
43
|
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&.c-divider--inverse {
|
|
47
|
+
--divider-bg-color: var(--dt-color-divider-inverse);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&.c-divider--vertical {
|
|
51
|
+
--divider-width: 1px;
|
|
52
|
+
--divider-height: 100%;
|
|
53
|
+
}
|
|
30
54
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
html, LitElement, unsafeCSS,
|
|
3
|
+
} from 'lit';
|
|
2
4
|
import { property } from 'lit/decorators.js';
|
|
3
|
-
import {
|
|
5
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
+
import { defineCustomElement, validPropertyValues } from '@justeattakeaway/pie-webc-core';
|
|
4
7
|
import styles from './divider.scss?inline';
|
|
5
8
|
import {
|
|
6
|
-
DividerProps,
|
|
9
|
+
type DividerProps, defaultProps, orientations, variants,
|
|
7
10
|
} from './defs';
|
|
8
11
|
|
|
9
12
|
// Valid values available to consumers
|
|
@@ -17,23 +20,44 @@ const componentSelector = 'pie-divider';
|
|
|
17
20
|
export class PieDivider extends LitElement implements DividerProps {
|
|
18
21
|
@property({ type: String })
|
|
19
22
|
@validPropertyValues(componentSelector, variants, defaultProps.variant)
|
|
20
|
-
public variant
|
|
23
|
+
public variant = defaultProps.variant;
|
|
21
24
|
|
|
22
25
|
@property({ type: String })
|
|
23
26
|
@validPropertyValues(componentSelector, orientations, defaultProps.orientation)
|
|
24
|
-
public orientation
|
|
27
|
+
public orientation = defaultProps.orientation;
|
|
28
|
+
|
|
29
|
+
@property({ type: String })
|
|
30
|
+
public label = defaultProps.label;
|
|
25
31
|
|
|
26
32
|
render () {
|
|
27
|
-
const { variant, orientation } = this;
|
|
33
|
+
const { variant, orientation, label } = this;
|
|
34
|
+
|
|
35
|
+
const showLabel = label.length > 0 && orientation === 'horizontal';
|
|
36
|
+
const classes = {
|
|
37
|
+
'c-divider': true,
|
|
38
|
+
'c-divider--inverse': variant === 'inverse',
|
|
39
|
+
'c-divider--vertical': orientation === 'vertical',
|
|
40
|
+
'c-divider--labelled': showLabel,
|
|
41
|
+
};
|
|
28
42
|
|
|
29
43
|
return html`
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
${showLabel ? html`
|
|
45
|
+
<div
|
|
46
|
+
id="${componentSelector}"
|
|
47
|
+
data-test-id="${componentSelector}"
|
|
48
|
+
class="${classMap(classes)}"
|
|
49
|
+
aria-labelledby="${componentSelector}-label">
|
|
50
|
+
<hr aria-hidden="true"/>
|
|
51
|
+
<span id="${componentSelector}-label" class="c-divider-label">${label}</span>
|
|
52
|
+
<hr aria-hidden="true"/>
|
|
53
|
+
</div>`
|
|
54
|
+
: html`
|
|
55
|
+
<hr id="${componentSelector}"
|
|
56
|
+
data-test-id="${componentSelector}"
|
|
57
|
+
class="${classMap(classes)}"
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
/>`
|
|
60
|
+
}`;
|
|
37
61
|
}
|
|
38
62
|
|
|
39
63
|
// Renders a `CSSResult` generated from SCSS by Vite
|