@justeattakeaway/pie-divider 0.13.9 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +11 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +52 -37
- package/dist/react.d.ts +5 -0
- package/dist/react.js +6 -10
- package/package.json +4 -4
- package/src/defs.ts +5 -0
- package/src/divider.scss +42 -10
- package/src/index.ts +26 -6
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": [
|
|
@@ -84,6 +84,12 @@
|
|
|
84
84
|
"name": "orientation",
|
|
85
85
|
"privacy": "public",
|
|
86
86
|
"attribute": "orientation"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"kind": "field",
|
|
90
|
+
"name": "label",
|
|
91
|
+
"privacy": "public",
|
|
92
|
+
"attribute": "label"
|
|
87
93
|
}
|
|
88
94
|
],
|
|
89
95
|
"attributes": [
|
|
@@ -94,6 +100,10 @@
|
|
|
94
100
|
{
|
|
95
101
|
"name": "orientation",
|
|
96
102
|
"fieldName": "orientation"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "label",
|
|
106
|
+
"fieldName": "label"
|
|
97
107
|
}
|
|
98
108
|
],
|
|
99
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"];
|
|
@@ -26,6 +30,7 @@ export declare const orientations: readonly ["horizontal", "vertical"];
|
|
|
26
30
|
export declare class PieDivider extends LitElement implements DividerProps {
|
|
27
31
|
variant: "default" | "inverse";
|
|
28
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,48 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { property as
|
|
3
|
-
import { classMap as
|
|
4
|
-
import { validPropertyValues as
|
|
5
|
-
const
|
|
6
|
-
`, y = ["default", "inverse"], P = ["horizontal", "vertical"], o = {
|
|
1
|
+
import { LitElement as m, html as n, unsafeCSS as f } from "lit";
|
|
2
|
+
import { property as v } from "lit/decorators.js";
|
|
3
|
+
import { classMap as b } from "lit/directives/class-map.js";
|
|
4
|
+
import { validPropertyValues as g, defineCustomElement as u } from "@justeattakeaway/pie-webc-core";
|
|
5
|
+
const w = "*,*: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%}", x = ["default", "inverse"], y = ["horizontal", "vertical"], a = {
|
|
7
6
|
variant: "default",
|
|
8
|
-
orientation: "horizontal"
|
|
7
|
+
orientation: "horizontal",
|
|
8
|
+
label: ""
|
|
9
9
|
};
|
|
10
|
-
var
|
|
11
|
-
for (var i =
|
|
12
|
-
(
|
|
13
|
-
return
|
|
10
|
+
var $ = Object.defineProperty, c = (h, l, t, o) => {
|
|
11
|
+
for (var i = void 0, r = h.length - 1, p; r >= 0; r--)
|
|
12
|
+
(p = h[r]) && (i = p(l, t, i) || i);
|
|
13
|
+
return i && $(l, t, i), i;
|
|
14
14
|
};
|
|
15
|
-
const
|
|
16
|
-
class d extends f {
|
|
15
|
+
const e = "pie-divider", s = class s extends m {
|
|
17
16
|
constructor() {
|
|
18
|
-
super(...arguments), this.variant =
|
|
17
|
+
super(...arguments), this.variant = a.variant, this.orientation = a.orientation, this.label = a.label;
|
|
19
18
|
}
|
|
20
19
|
render() {
|
|
21
|
-
const { variant:
|
|
22
|
-
return u`
|
|
23
|
-
<hr
|
|
24
|
-
data-test-id="pie-divider"
|
|
25
|
-
aria-hidden="true"
|
|
26
|
-
class="${m({
|
|
20
|
+
const { variant: l, orientation: t, label: o } = this, i = o.length > 0 && t === "horizontal", r = {
|
|
27
21
|
"c-divider": !0,
|
|
28
|
-
"c-divider--inverse":
|
|
29
|
-
"c-divider--vertical":
|
|
30
|
-
|
|
22
|
+
"c-divider--inverse": l === "inverse",
|
|
23
|
+
"c-divider--vertical": t === "vertical",
|
|
24
|
+
"c-divider--labelled": i
|
|
25
|
+
};
|
|
26
|
+
return n`
|
|
27
|
+
${i ? n`
|
|
28
|
+
<div
|
|
29
|
+
id="${e}"
|
|
30
|
+
data-test-id="${e}"
|
|
31
|
+
class="${b(r)}"
|
|
32
|
+
aria-labelledby="${e}-label">
|
|
33
|
+
<hr aria-hidden="true"/>
|
|
34
|
+
<span id="${e}-label" class="c-divider-label">${o}</span>
|
|
35
|
+
<hr aria-hidden="true"/>
|
|
36
|
+
</div>` : n`
|
|
37
|
+
<hr id="${e}"
|
|
38
|
+
data-test-id="${e}"
|
|
39
|
+
class="${b(r)}"
|
|
40
|
+
aria-hidden="true"
|
|
41
|
+
/>`}`;
|
|
31
42
|
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
};
|
|
44
|
+
s.styles = f(w);
|
|
45
|
+
let d = s;
|
|
46
|
+
c([
|
|
47
|
+
v({ type: String }),
|
|
48
|
+
g(e, x, a.variant)
|
|
49
|
+
], d.prototype, "variant");
|
|
50
|
+
c([
|
|
51
|
+
v({ type: String }),
|
|
52
|
+
g(e, y, a.orientation)
|
|
53
|
+
], d.prototype, "orientation");
|
|
54
|
+
c([
|
|
55
|
+
v({ type: String })
|
|
56
|
+
], d.prototype, "label");
|
|
57
|
+
u(e, d);
|
|
43
58
|
export {
|
|
44
59
|
d as PieDivider,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
60
|
+
a as defaultProps,
|
|
61
|
+
y as orientations,
|
|
62
|
+
x as variants
|
|
48
63
|
};
|
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"];
|
|
@@ -29,6 +33,7 @@ export declare const PieDivider: React_2.ForwardRefExoticComponent<DividerProps
|
|
|
29
33
|
declare class PieDivider_2 extends LitElement implements DividerProps {
|
|
30
34
|
variant: "default" | "inverse";
|
|
31
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,21 +1,17 @@
|
|
|
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
|
|
5
|
-
import "lit";
|
|
6
|
-
import "lit/decorators.js";
|
|
7
|
-
import "lit/directives/class-map.js";
|
|
8
|
-
import "@justeattakeaway/pie-webc-core";
|
|
4
|
+
import { defaultProps as n, orientations as p, variants as v } from "./index.js";
|
|
9
5
|
const t = i({
|
|
10
6
|
displayName: "PieDivider",
|
|
11
7
|
elementClass: r,
|
|
12
8
|
react: e,
|
|
13
9
|
tagName: "pie-divider",
|
|
14
10
|
events: {}
|
|
15
|
-
}),
|
|
11
|
+
}), m = t;
|
|
16
12
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
m as PieDivider,
|
|
14
|
+
n as defaultProps,
|
|
15
|
+
p as orientations,
|
|
16
|
+
v as variants
|
|
21
17
|
};
|
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.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
39
|
-
"@justeattakeaway/pie-components-config": "0.
|
|
40
|
-
"@justeattakeaway/pie-css": "0.
|
|
39
|
+
"@justeattakeaway/pie-components-config": "0.18.0",
|
|
40
|
+
"@justeattakeaway/pie-css": "0.13.0",
|
|
41
41
|
"@justeattakeaway/pie-wrapper-react": "0.14.1",
|
|
42
42
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@justeattakeaway/pie-webc-core": "0.24.
|
|
45
|
+
"@justeattakeaway/pie-webc-core": "0.24.1"
|
|
46
46
|
},
|
|
47
47
|
"volta": {
|
|
48
48
|
"extends": "../../../package.json"
|
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,22 +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
|
-
|
|
19
|
+
&:not(.c-divider--labelled) {
|
|
20
|
+
height: var(--divider-height);
|
|
21
|
+
}
|
|
22
|
+
|
|
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;
|
|
16
33
|
}
|
|
17
34
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
35
|
+
hr {
|
|
36
|
+
flex-grow: 1;
|
|
37
|
+
height: var(--divider-height);
|
|
38
|
+
min-width: var(--divider-min-width);
|
|
21
39
|
}
|
|
40
|
+
|
|
41
|
+
&.c-divider--inverse {
|
|
42
|
+
color: var(--dt-color-content-inverse);
|
|
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
|
+
}
|
|
22
54
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
html, LitElement, unsafeCSS,
|
|
3
|
+
} from 'lit';
|
|
2
4
|
import { property } from 'lit/decorators.js';
|
|
3
5
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
6
|
import { defineCustomElement, validPropertyValues } from '@justeattakeaway/pie-webc-core';
|
|
@@ -24,20 +26,38 @@ export class PieDivider extends LitElement implements DividerProps {
|
|
|
24
26
|
@validPropertyValues(componentSelector, orientations, defaultProps.orientation)
|
|
25
27
|
public orientation = defaultProps.orientation;
|
|
26
28
|
|
|
29
|
+
@property({ type: String })
|
|
30
|
+
public label = defaultProps.label;
|
|
31
|
+
|
|
27
32
|
render () {
|
|
28
|
-
const { variant, orientation } = this;
|
|
33
|
+
const { variant, orientation, label } = this;
|
|
29
34
|
|
|
35
|
+
const showLabel = label.length > 0 && orientation === 'horizontal';
|
|
30
36
|
const classes = {
|
|
31
37
|
'c-divider': true,
|
|
32
38
|
'c-divider--inverse': variant === 'inverse',
|
|
33
39
|
'c-divider--vertical': orientation === 'vertical',
|
|
40
|
+
'c-divider--labelled': showLabel,
|
|
34
41
|
};
|
|
35
42
|
|
|
36
43
|
return html`
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
}`;
|
|
41
61
|
}
|
|
42
62
|
|
|
43
63
|
// Renders a `CSSResult` generated from SCSS by Vite
|