@justeattakeaway/pie-webc-core 0.26.0 → 1.1.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/dist/index.js
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { customElement as a } from "lit/decorators.js";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(i, s, {
|
|
2
|
+
const d = (t, e, n) => function(i, r) {
|
|
3
|
+
const o = `#${r}`;
|
|
4
|
+
Object.defineProperty(i, r, {
|
|
6
5
|
get() {
|
|
7
6
|
return this[o];
|
|
8
7
|
},
|
|
9
8
|
set(c) {
|
|
10
9
|
e.includes(c) ? this[o] = c : (console.error(
|
|
11
|
-
`<${t}> Invalid value "${c}" provided for property "${
|
|
10
|
+
`<${t}> Invalid value "${c}" provided for property "${r}".`,
|
|
12
11
|
`Must be one of: ${e.join(" | ")}.`,
|
|
13
12
|
`Falling back to default value: "${n}"`
|
|
14
13
|
), this[o] = n);
|
|
15
14
|
},
|
|
16
15
|
configurable: !0
|
|
17
16
|
});
|
|
18
|
-
},
|
|
19
|
-
const i = `#${
|
|
20
|
-
Object.defineProperty(n,
|
|
17
|
+
}, l = (t) => function(n, s) {
|
|
18
|
+
const i = `#${s}`;
|
|
19
|
+
Object.defineProperty(n, s, {
|
|
21
20
|
get() {
|
|
22
21
|
return this[i];
|
|
23
22
|
},
|
|
24
|
-
set(
|
|
25
|
-
(
|
|
23
|
+
set(r) {
|
|
24
|
+
(r == null || typeof r == "string" && r.trim() === "") && console.error(`<${t}> Missing required attribute "${s}"`), this[i] = r;
|
|
26
25
|
},
|
|
27
26
|
configurable: !0
|
|
28
27
|
});
|
|
@@ -32,7 +31,7 @@ function h(t) {
|
|
|
32
31
|
try {
|
|
33
32
|
a(t)(e);
|
|
34
33
|
} catch (n) {
|
|
35
|
-
const
|
|
34
|
+
const s = customElements.get(t), i = s == null ? void 0 : s.v;
|
|
36
35
|
e.v !== i && console.warn(
|
|
37
36
|
`PIE Web Component: "${t}" was already registered with version: ${i ?? "No version data found. Icon components do not contain version data. If the component is not an icon, please report the missing version data."}.`,
|
|
38
37
|
n
|
|
@@ -40,7 +39,7 @@ function h(t) {
|
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
|
-
function
|
|
42
|
+
function b(t) {
|
|
44
43
|
return new CustomEvent(t.type, {
|
|
45
44
|
detail: {
|
|
46
45
|
sourceEvent: t
|
|
@@ -49,32 +48,48 @@ function p(t) {
|
|
|
49
48
|
cancelable: t.cancelable
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
|
-
function
|
|
51
|
+
function m(t, e, n) {
|
|
53
52
|
e.startsWith("pie-") || console.warn("A custom event name should start with `pie-`");
|
|
54
|
-
const
|
|
53
|
+
const s = new CustomEvent(e, {
|
|
55
54
|
bubbles: !0,
|
|
56
55
|
composed: !0,
|
|
57
56
|
detail: n
|
|
58
57
|
});
|
|
59
|
-
t.dispatchEvent(
|
|
58
|
+
t.dispatchEvent(s);
|
|
60
59
|
}
|
|
61
|
-
const
|
|
60
|
+
const p = (t) => {
|
|
62
61
|
class e extends t {
|
|
62
|
+
constructor() {
|
|
63
|
+
super(...arguments), this._isRTL = !1, this.observer = null;
|
|
64
|
+
}
|
|
65
|
+
get isRTL() {
|
|
66
|
+
return this._isRTL;
|
|
67
|
+
}
|
|
68
|
+
set isRTL(s) {
|
|
69
|
+
this._isRTL = s, this.requestUpdate();
|
|
70
|
+
}
|
|
71
|
+
connectedCallback() {
|
|
72
|
+
super.connectedCallback(), this.handleWritingDirectionUpdate(), this.observer = new MutationObserver(() => {
|
|
73
|
+
this.handleWritingDirectionUpdate();
|
|
74
|
+
}), this.observer.observe(document.documentElement, {
|
|
75
|
+
attributeFilter: ["dir"],
|
|
76
|
+
subtree: !0
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
disconnectedCallback() {
|
|
80
|
+
super.disconnectedCallback(), this.observer && (this.observer.disconnect(), this.observer = null);
|
|
81
|
+
}
|
|
63
82
|
/**
|
|
64
|
-
* A getter to determine whether the text direction is right-to-left (RTL).
|
|
65
83
|
* If the `dir` property is present on the component, it will be used to determine the text direction.
|
|
66
|
-
* If
|
|
67
|
-
*
|
|
68
|
-
* In all other cases, it will return `false`, indicating a left-to-right (LTR) text direction.
|
|
69
|
-
*
|
|
70
|
-
* @returns {boolean} - Returns `true` if the text direction is RTL, otherwise `false`.
|
|
84
|
+
* If the `dir` property is not present, the text direction will be inferred from the document's root element.
|
|
85
|
+
* otherwise the default value is `false`, indicating a left-to-right (LTR) text direction.
|
|
71
86
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
handleWritingDirectionUpdate() {
|
|
88
|
+
this.isRTL = this.dir === "rtl" || document.documentElement.getAttribute("dir") === "rtl";
|
|
74
89
|
}
|
|
75
90
|
}
|
|
76
91
|
return e;
|
|
77
|
-
},
|
|
92
|
+
}, f = (t) => {
|
|
78
93
|
const n = class n extends t {
|
|
79
94
|
get form() {
|
|
80
95
|
return this._internals.form;
|
|
@@ -89,11 +104,11 @@ const g = (t) => {
|
|
|
89
104
|
return e;
|
|
90
105
|
};
|
|
91
106
|
export {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
107
|
+
f as FormControlMixin,
|
|
108
|
+
p as RtlMixin,
|
|
109
|
+
m as dispatchCustomEvent,
|
|
110
|
+
l as requiredProperty,
|
|
96
111
|
h as safeCustomElement,
|
|
97
|
-
|
|
98
|
-
|
|
112
|
+
d as validPropertyValues,
|
|
113
|
+
b as wrapNativeEvent
|
|
99
114
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-webc-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "PIE design system base classes, mixins and utilities for web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lit": "3.2.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@justeattakeaway/pie-components-config": "0.
|
|
31
|
+
"@justeattakeaway/pie-components-config": "0.21.0"
|
|
32
32
|
},
|
|
33
33
|
"volta": {
|
|
34
34
|
"extends": "../../../package.json"
|
|
@@ -50,6 +50,8 @@ export const FormControlMixin =
|
|
|
50
50
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
51
|
constructor (...args: any[]) {
|
|
52
52
|
super(...args);
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
54
|
+
// @ts-ignore
|
|
53
55
|
this._internals = this.attachInternals();
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LitElement
|
|
1
|
+
import { type LitElement } from 'lit';
|
|
2
2
|
import { type GenericConstructor } from '../types/GenericConstructor';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -63,26 +63,47 @@ export const RtlMixin =
|
|
|
63
63
|
* @implements {RTLInterface}
|
|
64
64
|
*/
|
|
65
65
|
class RTLElement extends superClass implements RTLInterface {
|
|
66
|
+
private _isRTL = false;
|
|
67
|
+
|
|
68
|
+
get isRTL () {
|
|
69
|
+
return this._isRTL;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
set isRTL (val: boolean) {
|
|
73
|
+
this._isRTL = val;
|
|
74
|
+
this.requestUpdate();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private observer: MutationObserver | null = null;
|
|
78
|
+
|
|
79
|
+
connectedCallback () {
|
|
80
|
+
super.connectedCallback();
|
|
81
|
+
this.handleWritingDirectionUpdate();
|
|
82
|
+
|
|
83
|
+
this.observer = new MutationObserver(() => {
|
|
84
|
+
this.handleWritingDirectionUpdate();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
this.observer.observe(document.documentElement, {
|
|
88
|
+
attributeFilter: ['dir'],
|
|
89
|
+
subtree: true,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
disconnectedCallback () {
|
|
94
|
+
super.disconnectedCallback();
|
|
95
|
+
if (!this.observer) return;
|
|
96
|
+
this.observer.disconnect();
|
|
97
|
+
this.observer = null;
|
|
98
|
+
}
|
|
99
|
+
|
|
66
100
|
/**
|
|
67
|
-
* A getter to determine whether the text direction is right-to-left (RTL).
|
|
68
101
|
* If the `dir` property is present on the component, it will be used to determine the text direction.
|
|
69
|
-
* If
|
|
70
|
-
*
|
|
71
|
-
* In all other cases, it will return `false`, indicating a left-to-right (LTR) text direction.
|
|
72
|
-
*
|
|
73
|
-
* @returns {boolean} - Returns `true` if the text direction is RTL, otherwise `false`.
|
|
102
|
+
* If the `dir` property is not present, the text direction will be inferred from the document's root element.
|
|
103
|
+
* otherwise the default value is `false`, indicating a left-to-right (LTR) text direction.
|
|
74
104
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return this.dir === 'rtl';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// If running on client-side and `dir` is not present, infer from the document's root element.
|
|
81
|
-
if (!isServer && !this.dir) {
|
|
82
|
-
return document.documentElement.getAttribute('dir') === 'rtl';
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return false;
|
|
105
|
+
private handleWritingDirectionUpdate () {
|
|
106
|
+
this.isRTL = this.dir === 'rtl' || document.documentElement.getAttribute('dir') === 'rtl';
|
|
86
107
|
}
|
|
87
108
|
}
|
|
88
109
|
|