@justeattakeaway/pie-switch 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.
package/dist/react.d.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  import type { CSSResult } from 'lit';
2
- import type { EventName } from '@lit/react';
3
2
  import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
4
3
  import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
5
4
  import type { LitElement } from 'lit';
6
5
  import type { PropertyValues } from 'lit';
7
- import type { ReactWebComponent } from '@lit/react';
6
+ import * as React_2 from 'react';
8
7
  import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
9
8
  import type { TemplateResult } from 'lit';
10
9
 
@@ -24,10 +23,7 @@ export declare const labelPlacements: readonly ["leading", "trailing"];
24
23
  */
25
24
  export declare const ON_SWITCH_CHANGED_EVENT = "change";
26
25
 
27
- export declare const PieSwitch: ReactWebComponent<PieSwitch_2, {
28
- onInvalid: EventName<Event>;
29
- onChange: EventName<CustomEvent<any>>;
30
- }>;
26
+ export declare const PieSwitch: React_2.ForwardRefExoticComponent<SwitchProps & React_2.RefAttributes<PieSwitch_2> & PieSwitchEvents & ReactBaseType>;
31
27
 
32
28
  /**
33
29
  * @tagname pie-switch
@@ -95,6 +91,13 @@ declare class PieSwitch_2 extends PieSwitch_base implements SwitchProps {
95
91
 
96
92
  declare const PieSwitch_base: GenericConstructor<FormControlInterface> & GenericConstructor<RTLInterface> & typeof LitElement;
97
93
 
94
+ declare type PieSwitchEvents = {
95
+ onInvalid?: (event: Event) => void;
96
+ onChange?: (event: CustomEvent) => void;
97
+ };
98
+
99
+ declare type ReactBaseType = React_2.InputHTMLAttributes<HTMLInputElement>;
100
+
98
101
  export declare interface SwitchProps {
99
102
  /**
100
103
  * The ARIA labels used for the switch.
@@ -107,7 +110,7 @@ export declare interface SwitchProps {
107
110
  /**
108
111
  * Same as the HTML required attribute - indicates whether the switch must be turned or not
109
112
  */
110
- required: boolean;
113
+ required?: boolean;
111
114
  /**
112
115
  * Same as the HTML disabled attribute - indicates whether the switch is disabled or not
113
116
  */
@@ -127,7 +130,7 @@ export declare interface SwitchProps {
127
130
  /**
128
131
  * Same as the HTML value attribute - indicates the value of the switch (for use with forms). Defaults to 'on'.
129
132
  */
130
- value: string;
133
+ value?: string;
131
134
  }
132
135
 
133
136
  export { }
package/dist/react.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as e from "react";
2
2
  import { createComponent as t } from "@lit/react";
3
3
  import { PieSwitch as i } from "./index.js";
4
- import { ON_SWITCH_CHANGED_EVENT as h, labelPlacements as w } from "./index.js";
4
+ import { ON_SWITCH_CHANGED_EVENT as w, labelPlacements as P } from "./index.js";
5
5
  import "lit";
6
6
  import "lit/decorators.js";
7
7
  import "@justeattakeaway/pie-webc-core";
8
8
  import "@justeattakeaway/pie-icons-webc/IconCheck";
9
- const c = t({
9
+ const o = t({
10
10
  displayName: "PieSwitch",
11
11
  elementClass: i,
12
12
  react: e,
@@ -16,9 +16,9 @@ const c = t({
16
16
  onChange: "change"
17
17
  // when the switch checked state is changed.
18
18
  }
19
- });
19
+ }), s = o;
20
20
  export {
21
- h as ON_SWITCH_CHANGED_EVENT,
22
- c as PieSwitch,
23
- w as labelPlacements
21
+ w as ON_SWITCH_CHANGED_EVENT,
22
+ s as PieSwitch,
23
+ P as labelPlacements
24
24
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-switch",
3
3
  "description": "PIE Design System Switch built using Web Components",
4
- "version": "0.23.0",
4
+ "version": "0.24.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -32,14 +32,14 @@
32
32
  "license": "Apache-2.0",
33
33
  "devDependencies": {
34
34
  "@custom-elements-manifest/analyzer": "0.9.0",
35
- "@justeattakeaway/pie-components-config": "0.8.0",
35
+ "@justeattakeaway/pie-components-config": "0.9.0",
36
36
  "cem-plugin-module-file-extensions": "0.0.5"
37
37
  },
38
38
  "dependencies": {
39
- "@justeattakeaway/pie-icons-webc": "0.17.0",
40
- "@justeattakeaway/pie-webc-core": "0.16.0",
41
- "@justeattakeaway/pie-wrapper-react": "0.12.0",
42
- "element-internals-polyfill": "1.3.9"
39
+ "@justeattakeaway/pie-icons-webc": "0.17.2",
40
+ "@justeattakeaway/pie-webc-core": "0.17.1",
41
+ "@justeattakeaway/pie-wrapper-react": "0.14.0",
42
+ "element-internals-polyfill": "1.3.10"
43
43
  },
44
44
  "volta": {
45
45
  "extends": "../../../package.json"
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+
3
+ export type ReactBaseType = React.InputHTMLAttributes<HTMLInputElement>
package/src/defs.ts CHANGED
@@ -19,7 +19,7 @@ export interface SwitchProps {
19
19
  /**
20
20
  * Same as the HTML required attribute - indicates whether the switch must be turned or not
21
21
  */
22
- required: boolean;
22
+ required?: boolean;
23
23
  /**
24
24
  * Same as the HTML disabled attribute - indicates whether the switch is disabled or not
25
25
  */
@@ -39,7 +39,7 @@ export interface SwitchProps {
39
39
  /**
40
40
  * Same as the HTML value attribute - indicates the value of the switch (for use with forms). Defaults to 'on'.
41
41
  */
42
- value: string;
42
+ value?: string;
43
43
  }
44
44
 
45
45
  /**
package/src/index.ts CHANGED
@@ -3,11 +3,11 @@ import {
3
3
  } from 'lit';
4
4
  import { property, query } from 'lit/decorators.js';
5
5
  import {
6
- RtlMixin, validPropertyValues, defineCustomElement, FormControlMixin,
6
+ RtlMixin, validPropertyValues, defineCustomElement, FormControlMixin, wrapNativeEvent,
7
7
  } from '@justeattakeaway/pie-webc-core';
8
8
  import styles from './switch.scss?inline';
9
9
  import {
10
- SwitchProps, ON_SWITCH_CHANGED_EVENT, AriaProps, labelPlacements,
10
+ SwitchProps, AriaProps, labelPlacements,
11
11
  } from './defs';
12
12
  import 'element-internals-polyfill';
13
13
  import '@justeattakeaway/pie-icons-webc/IconCheck';
@@ -94,13 +94,7 @@ export class PieSwitch extends FormControlMixin(RtlMixin(LitElement)) implements
94
94
  onChange (event: Event) {
95
95
  const { checked } = event?.currentTarget as HTMLInputElement;
96
96
  this.checked = checked;
97
- const changedEvent = new CustomEvent(
98
- ON_SWITCH_CHANGED_EVENT,
99
- {
100
- bubbles: true,
101
- composed: true,
102
- },
103
- );
97
+ const changedEvent = wrapNativeEvent(event);
104
98
 
105
99
  this.dispatchEvent(changedEvent);
106
100
  this.handleFormAssociation();
package/src/react.ts CHANGED
@@ -1,13 +1,13 @@
1
-
2
1
  import * as React from 'react';
3
2
  import { createComponent, EventName } from '@lit/react';
4
- import { PieSwitch as PieSwitchReact } from './index';
3
+ import { PieSwitch as PieSwitchLit } from './index';
4
+ import { SwitchProps } from './defs';
5
5
 
6
6
  export * from './defs';
7
7
 
8
- export const PieSwitch = createComponent({
8
+ const PieSwitchReact = createComponent({
9
9
  displayName: 'PieSwitch',
10
- elementClass: PieSwitchReact,
10
+ elementClass: PieSwitchLit,
11
11
  react: React,
12
12
  tagName: 'pie-switch',
13
13
  events: {
@@ -15,3 +15,13 @@ export const PieSwitch = createComponent({
15
15
  onChange: 'change' as EventName<CustomEvent>, // when the switch checked state is changed.
16
16
  },
17
17
  });
18
+
19
+ type ReactBaseType = React.InputHTMLAttributes<HTMLInputElement>
20
+
21
+ type PieSwitchEvents = {
22
+ onInvalid?: (event: Event) => void;
23
+ onChange?: (event: CustomEvent) => void;
24
+ };
25
+
26
+ export const PieSwitch = PieSwitchReact as React.ForwardRefExoticComponent<React.PropsWithoutRef<SwitchProps>
27
+ & React.RefAttributes<PieSwitchLit> & PieSwitchEvents & ReactBaseType>;