@justeattakeaway/pie-webc-core 0.23.0 → 0.24.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.
@@ -1,7 +1,7 @@
1
- vite v4.5.3 building for production...
1
+ vite v5.3.6 building for production...
2
2
  transforming...
3
3
  ✓ 16 modules transformed.
4
4
  rendering chunks...
5
5
  computing gzip size...
6
- dist/index.js 2.66 kB │ gzip: 1.20 kB
7
- ✓ built in 196ms
6
+ dist/index.js 2.69 kB │ gzip: 1.23 kB
7
+ ✓ built in 108ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.24.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [Changed] - Suggested package updates for security ([#1953](https://github.com/justeattakeaway/pie/pull/1953)) by [@xander-marjoram](https://github.com/xander-marjoram)
8
+
9
+ ## 0.24.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [Changed] - Update default props generic helper type to include all props by default ([#1582](https://github.com/justeattakeaway/pie/pull/1582)) by [@xander-marjoram](https://github.com/xander-marjoram)
14
+
15
+ [Changed] - Naming of generic type
16
+ [Added] - JSDoc comment
17
+
3
18
  ## 0.23.0
4
19
 
5
20
  ### Minor Changes
package/dist/index.js CHANGED
@@ -1,27 +1,27 @@
1
- import { isServer as c } from "lit";
2
- const a = (t, e, r) => function(s, n) {
3
- const o = `#${n}`;
4
- Object.defineProperty(s, n, {
1
+ import { isServer as u } from "lit";
2
+ const d = (t, e, n) => function(s, r) {
3
+ const o = `#${r}`;
4
+ Object.defineProperty(s, r, {
5
5
  get() {
6
6
  return this[o];
7
7
  },
8
- set(u) {
9
- e.includes(u) ? this[o] = u : (console.error(
10
- `<${t}> Invalid value "${u}" provided for property "${n}".`,
8
+ set(c) {
9
+ e.includes(c) ? this[o] = c : (console.error(
10
+ `<${t}> Invalid value "${c}" provided for property "${r}".`,
11
11
  `Must be one of: ${e.join(" | ")}.`,
12
- `Falling back to default value: "${r}"`
13
- ), this[o] = r);
12
+ `Falling back to default value: "${n}"`
13
+ ), this[o] = n);
14
14
  },
15
15
  configurable: !0
16
16
  });
17
- }, d = (t) => function(r, i) {
17
+ }, l = (t) => function(n, i) {
18
18
  const s = `#${i}`;
19
- Object.defineProperty(r, i, {
19
+ Object.defineProperty(n, i, {
20
20
  get() {
21
21
  return this[s];
22
22
  },
23
- set(n) {
24
- (n == null || typeof n == "string" && n.trim() === "") && console.error(`<${t}> Missing required attribute "${i}"`), this[s] = n;
23
+ set(r) {
24
+ (r == null || typeof r == "string" && r.trim() === "") && console.error(`<${t}> Missing required attribute "${i}"`), this[s] = r;
25
25
  },
26
26
  configurable: !0
27
27
  });
@@ -29,7 +29,7 @@ const a = (t, e, r) => function(s, n) {
29
29
  function f(t, e) {
30
30
  customElements.get(t) ? console.warn(`PIE Web Component: "${t}" has already been defined. Please ensure the component is only being defined once in your application.`) : customElements.define(t, e);
31
31
  }
32
- function m(t) {
32
+ function b(t) {
33
33
  return new CustomEvent(t.type, {
34
34
  detail: {
35
35
  sourceEvent: t
@@ -38,16 +38,16 @@ function m(t) {
38
38
  cancelable: t.cancelable
39
39
  });
40
40
  }
41
- function b(t, e, r) {
41
+ function h(t, e, n) {
42
42
  e.startsWith("pie-") || console.warn("A custom event name should start with `pie-`");
43
43
  const i = new CustomEvent(e, {
44
44
  bubbles: !0,
45
45
  composed: !0,
46
- detail: r
46
+ detail: n
47
47
  });
48
48
  t.dispatchEvent(i);
49
49
  }
50
- const h = (t) => {
50
+ const m = (t) => {
51
51
  class e extends t {
52
52
  /**
53
53
  * A getter to determine whether the text direction is right-to-left (RTL).
@@ -59,28 +59,30 @@ const h = (t) => {
59
59
  * @returns {boolean} - Returns `true` if the text direction is RTL, otherwise `false`.
60
60
  */
61
61
  get isRTL() {
62
- return this.dir ? this.dir === "rtl" : !c && !this.dir ? document.documentElement.getAttribute("dir") === "rtl" : !1;
62
+ return this.dir ? this.dir === "rtl" : !u && !this.dir ? document.documentElement.getAttribute("dir") === "rtl" : !1;
63
63
  }
64
64
  }
65
65
  return e;
66
66
  }, p = (t) => {
67
- class e extends t {
68
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
- constructor(...i) {
70
- super(...i), this._internals = this.attachInternals();
71
- }
67
+ const n = class n extends t {
72
68
  get form() {
73
69
  return this._internals.form;
74
70
  }
75
- }
76
- return e.formAssociated = !0, e;
71
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
+ constructor(...s) {
73
+ super(...s), this._internals = this.attachInternals();
74
+ }
75
+ };
76
+ n.formAssociated = !0;
77
+ let e = n;
78
+ return e;
77
79
  };
78
80
  export {
79
81
  p as FormControlMixin,
80
- h as RtlMixin,
82
+ m as RtlMixin,
81
83
  f as defineCustomElement,
82
- b as dispatchCustomEvent,
83
- d as requiredProperty,
84
- a as validPropertyValues,
85
- m as wrapNativeEvent
84
+ h as dispatchCustomEvent,
85
+ l as requiredProperty,
86
+ d as validPropertyValues,
87
+ b as wrapNativeEvent
86
88
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-webc-core",
3
- "version": "0.23.0",
3
+ "version": "0.24.1",
4
4
  "description": "PIE design system base classes, mixins and utilities for web components",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,10 +18,10 @@
18
18
  "test:watch": "run -T vitest"
19
19
  },
20
20
  "dependencies": {
21
- "lit": "3.1.3"
21
+ "lit": "3.2.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@justeattakeaway/pie-components-config": "0.16.0"
24
+ "@justeattakeaway/pie-components-config": "0.18.0"
25
25
  },
26
26
  "volta": {
27
27
  "extends": "../../../package.json"
@@ -41,16 +41,16 @@ export interface RTLInterface {
41
41
  *
42
42
  * class MyStyledElement extends RtlMixin(LitElement) {
43
43
  * render() {
44
- * return html`<div class="foo" ?isRTL=${this.isRTL}>Content</div>`;
44
+ * return html`<div class="foo" ?data-is-rtl=${this.isRTL}>Content</div>`;
45
45
  * }
46
46
  * }
47
47
  *
48
48
  * customElements.define('my-styled-element', MyStyledElement);
49
49
  * ```
50
50
  *
51
- * The corresponding SCSS to leverage the `isRTL` attribute:
51
+ * The corresponding SCSS to leverage the `data-is-rtl` attribute:
52
52
  * ```scss
53
- * .foo[isRTL] {
53
+ * .foo[data-is-rtl] {
54
54
  * background-color: red;
55
55
  * text-align: right;
56
56
  * }
@@ -1 +1,31 @@
1
- export type ComponentDefaultPropsGeneric<T, K extends keyof T> = Readonly<Required<Pick<T, K>>>;
1
+ /**
2
+ * This type should be used when defining the default props for a component.
3
+ * It is a generic type that takes two type parameters:
4
+ * - `T` is the type of the props object that the default props are being defined for.
5
+ * - `K` is the type of the keys in `T` that should be required in the default props.
6
+ * By default, `K` is set to be all the keys in `T`. This means that all the keys in `T` will be required in the default props.
7
+ * You can override this by specifying a subset of the keys in `T` that should be required in the default props.
8
+ *
9
+ * @example ```tsx
10
+ * interface MyComponentProps {
11
+ * a: string;
12
+ * b?: number;
13
+ * c: boolean;
14
+ * }
15
+ * const allProps: ComponentDefaultProps<MyComponentProps> = {
16
+ * a: 'default value',
17
+ * b: 42,
18
+ * c: true,
19
+ * };
20
+ *
21
+ * const pickProps: ComponentDefaultProps<MyComponentProps, 'a'> = {
22
+ * a: 'default value',
23
+ * };
24
+ *
25
+ * const omitProps: ComponentDefaultProps<MyComponentProps, keyof Omit<MyComponentProps, 'a'>> = {
26
+ * b: 42,
27
+ * c: true,
28
+ * };
29
+ * ```
30
+ */
31
+ export type ComponentDefaultProps<T, K extends keyof T = keyof T> = Readonly<Required<Pick<T, K>>>;