@justeattakeaway/pie-radio 0.0.0 → 0.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/custom-elements.json +118 -3
- package/dist/index.d.ts +45 -1
- package/dist/index.js +75 -9
- package/dist/react.d.ts +46 -2
- package/dist/react.js +11 -6
- package/package.json +1 -1
- package/src/defs-react.ts +3 -8
- package/src/defs.ts +44 -3
- package/src/index.ts +55 -4
- package/src/react.ts +1 -1
package/custom-elements.json
CHANGED
|
@@ -11,8 +11,26 @@
|
|
|
11
11
|
{
|
|
12
12
|
"kind": "javascript-module",
|
|
13
13
|
"path": "src/defs.js",
|
|
14
|
-
"declarations": [
|
|
15
|
-
|
|
14
|
+
"declarations": [
|
|
15
|
+
{
|
|
16
|
+
"kind": "variable",
|
|
17
|
+
"name": "defaultProps",
|
|
18
|
+
"type": {
|
|
19
|
+
"text": "DefaultProps"
|
|
20
|
+
},
|
|
21
|
+
"default": "{\n checked: false,\n defaultChecked: false,\n disabled: false,\n required: false,\n}"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"exports": [
|
|
25
|
+
{
|
|
26
|
+
"kind": "js",
|
|
27
|
+
"name": "defaultProps",
|
|
28
|
+
"declaration": {
|
|
29
|
+
"name": "defaultProps",
|
|
30
|
+
"module": "src/defs.js"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
]
|
|
16
34
|
},
|
|
17
35
|
{
|
|
18
36
|
"kind": "javascript-module",
|
|
@@ -22,8 +40,105 @@
|
|
|
22
40
|
"kind": "class",
|
|
23
41
|
"description": "",
|
|
24
42
|
"name": "PieRadio",
|
|
25
|
-
"members": [
|
|
43
|
+
"members": [
|
|
44
|
+
{
|
|
45
|
+
"kind": "field",
|
|
46
|
+
"name": "checked",
|
|
47
|
+
"privacy": "public",
|
|
48
|
+
"attribute": "checked"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"kind": "field",
|
|
52
|
+
"name": "defaultChecked",
|
|
53
|
+
"privacy": "public",
|
|
54
|
+
"attribute": "defaultChecked"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"kind": "field",
|
|
58
|
+
"name": "disabled",
|
|
59
|
+
"privacy": "public",
|
|
60
|
+
"attribute": "disabled"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"kind": "field",
|
|
64
|
+
"name": "name",
|
|
65
|
+
"type": {
|
|
66
|
+
"text": "RadioProps['name']"
|
|
67
|
+
},
|
|
68
|
+
"privacy": "public",
|
|
69
|
+
"attribute": "name"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"kind": "field",
|
|
73
|
+
"name": "required",
|
|
74
|
+
"privacy": "public",
|
|
75
|
+
"attribute": "required"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"kind": "field",
|
|
79
|
+
"name": "value",
|
|
80
|
+
"type": {
|
|
81
|
+
"text": "RadioProps['value']"
|
|
82
|
+
},
|
|
83
|
+
"privacy": "public",
|
|
84
|
+
"attribute": "value"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"kind": "field",
|
|
88
|
+
"name": "radio",
|
|
89
|
+
"type": {
|
|
90
|
+
"text": "HTMLInputElement"
|
|
91
|
+
},
|
|
92
|
+
"privacy": "private"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"kind": "field",
|
|
96
|
+
"name": "validity",
|
|
97
|
+
"type": {
|
|
98
|
+
"text": "ValidityState"
|
|
99
|
+
},
|
|
100
|
+
"privacy": "public",
|
|
101
|
+
"description": "(Read-only) returns a ValidityState with the validity states that this element is in.\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity",
|
|
102
|
+
"readonly": true
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"attributes": [
|
|
106
|
+
{
|
|
107
|
+
"name": "checked",
|
|
108
|
+
"fieldName": "checked"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "defaultChecked",
|
|
112
|
+
"fieldName": "defaultChecked"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "disabled",
|
|
116
|
+
"fieldName": "disabled"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "name",
|
|
120
|
+
"type": {
|
|
121
|
+
"text": "RadioProps['name']"
|
|
122
|
+
},
|
|
123
|
+
"fieldName": "name"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "required",
|
|
127
|
+
"fieldName": "required"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"name": "value",
|
|
131
|
+
"type": {
|
|
132
|
+
"text": "RadioProps['value']"
|
|
133
|
+
},
|
|
134
|
+
"fieldName": "value"
|
|
135
|
+
}
|
|
136
|
+
],
|
|
26
137
|
"mixins": [
|
|
138
|
+
{
|
|
139
|
+
"name": "FormControlMixin",
|
|
140
|
+
"package": "@justeattakeaway/pie-webc-core"
|
|
141
|
+
},
|
|
27
142
|
{
|
|
28
143
|
"name": "RtlMixin",
|
|
29
144
|
"package": "@justeattakeaway/pie-webc-core"
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,64 @@
|
|
|
1
|
+
import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
1
2
|
import type { CSSResult } from 'lit';
|
|
3
|
+
import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
|
|
2
4
|
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
3
5
|
import type { LitElement } from 'lit';
|
|
4
6
|
import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
5
7
|
import type { TemplateResult } from 'lit-html';
|
|
6
8
|
|
|
9
|
+
export declare type DefaultProps = ComponentDefaultProps<RadioProps, keyof Omit<RadioProps, 'name' | 'value'>>;
|
|
10
|
+
|
|
11
|
+
export declare const defaultProps: DefaultProps;
|
|
12
|
+
|
|
7
13
|
/**
|
|
8
14
|
* @tagname pie-radio
|
|
9
15
|
*/
|
|
10
16
|
export declare class PieRadio extends PieRadio_base implements RadioProps {
|
|
17
|
+
checked: boolean;
|
|
18
|
+
defaultChecked: boolean;
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
name: RadioProps['name'];
|
|
21
|
+
required: boolean;
|
|
22
|
+
value: RadioProps['value'];
|
|
23
|
+
private radio;
|
|
24
|
+
/**
|
|
25
|
+
* (Read-only) returns a ValidityState with the validity states that this element is in.
|
|
26
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
|
|
27
|
+
*/
|
|
28
|
+
get validity(): ValidityState;
|
|
11
29
|
render(): TemplateResult<1>;
|
|
12
30
|
static styles: CSSResult;
|
|
13
31
|
}
|
|
14
32
|
|
|
15
|
-
declare const PieRadio_base: GenericConstructor<RTLInterface> & typeof LitElement;
|
|
33
|
+
declare const PieRadio_base: GenericConstructor<FormControlInterface> & GenericConstructor<RTLInterface> & typeof LitElement;
|
|
16
34
|
|
|
17
35
|
export declare interface RadioProps {
|
|
36
|
+
/**
|
|
37
|
+
* The checked state of the radio.
|
|
38
|
+
*/
|
|
39
|
+
checked?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The default checked state of the radio (not necessarily the same as the current checked state).
|
|
42
|
+
* Used when the radio is part of a form that is reset.
|
|
43
|
+
*/
|
|
44
|
+
defaultChecked?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Same as the HTML disabled attribute - indicates whether or not the radio is disabled.
|
|
47
|
+
*/
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The name of the radio (used as a key/value pair with `value`). This is required in order to work properly with forms.
|
|
51
|
+
*/
|
|
52
|
+
name?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Same as native required attribute. If any radio button in a same-named group of radio buttons has the required attribute,
|
|
55
|
+
* a radio button in that group must be checked, although it doesn't have to be the one with the attribute applied.
|
|
56
|
+
*/
|
|
57
|
+
required?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The value of the radio (used as a key/value pair in HTML forms with `name`).
|
|
60
|
+
*/
|
|
61
|
+
value: string;
|
|
18
62
|
}
|
|
19
63
|
|
|
20
64
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,80 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { LitElement as u, html as f, unsafeCSS as y } from "lit";
|
|
2
|
+
import { property as d, query as m } from "lit/decorators.js";
|
|
3
|
+
import { ifDefined as h } from "lit/directives/if-defined.js";
|
|
4
|
+
import { live as b } from "lit/directives/live.js";
|
|
5
|
+
import { FormControlMixin as v, RtlMixin as q, requiredProperty as C, defineCustomElement as P } from "@justeattakeaway/pie-webc-core";
|
|
6
|
+
const _ = `*,*:after,*:before{box-sizing:inherit}
|
|
7
|
+
`, p = {
|
|
8
|
+
checked: !1,
|
|
9
|
+
defaultChecked: !1,
|
|
10
|
+
disabled: !1,
|
|
11
|
+
required: !1
|
|
12
|
+
};
|
|
13
|
+
var g = Object.defineProperty, k = Object.getOwnPropertyDescriptor, r = (s, o, a, i) => {
|
|
14
|
+
for (var e = i > 1 ? void 0 : i ? k(o, a) : o, l = s.length - 1, n; l >= 0; l--)
|
|
15
|
+
(n = s[l]) && (e = (i ? n(o, a, e) : n(e)) || e);
|
|
16
|
+
return i && e && g(o, a, e), e;
|
|
17
|
+
};
|
|
18
|
+
const c = "pie-radio";
|
|
19
|
+
class t extends v(q(u)) {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments), this.checked = p.checked, this.defaultChecked = p.defaultChecked, this.disabled = p.disabled, this.required = p.required;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* (Read-only) returns a ValidityState with the validity states that this element is in.
|
|
25
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
|
|
26
|
+
*/
|
|
27
|
+
get validity() {
|
|
28
|
+
return this.radio.validity;
|
|
29
|
+
}
|
|
6
30
|
render() {
|
|
7
|
-
|
|
31
|
+
const {
|
|
32
|
+
checked: o,
|
|
33
|
+
disabled: a,
|
|
34
|
+
name: i,
|
|
35
|
+
required: e,
|
|
36
|
+
value: l
|
|
37
|
+
} = this;
|
|
38
|
+
return f`
|
|
39
|
+
<input
|
|
40
|
+
type="radio"
|
|
41
|
+
id="radioId"
|
|
42
|
+
data-test-id="pie-radio"
|
|
43
|
+
.checked="${b(o)}"
|
|
44
|
+
.value="${l}"
|
|
45
|
+
name="${h(i)}"
|
|
46
|
+
?disabled="${a}"
|
|
47
|
+
?required="${e}">
|
|
48
|
+
<label for="radioId">
|
|
49
|
+
<slot></slot>
|
|
50
|
+
</label>`;
|
|
8
51
|
}
|
|
9
52
|
}
|
|
10
|
-
|
|
11
|
-
|
|
53
|
+
t.styles = y(_);
|
|
54
|
+
r([
|
|
55
|
+
d({ type: Boolean })
|
|
56
|
+
], t.prototype, "checked", 2);
|
|
57
|
+
r([
|
|
58
|
+
d({ type: Boolean })
|
|
59
|
+
], t.prototype, "defaultChecked", 2);
|
|
60
|
+
r([
|
|
61
|
+
d({ type: Boolean })
|
|
62
|
+
], t.prototype, "disabled", 2);
|
|
63
|
+
r([
|
|
64
|
+
d({ type: String })
|
|
65
|
+
], t.prototype, "name", 2);
|
|
66
|
+
r([
|
|
67
|
+
d({ type: Boolean })
|
|
68
|
+
], t.prototype, "required", 2);
|
|
69
|
+
r([
|
|
70
|
+
d({ type: String }),
|
|
71
|
+
C(c)
|
|
72
|
+
], t.prototype, "value", 2);
|
|
73
|
+
r([
|
|
74
|
+
m('input[type="radio"]')
|
|
75
|
+
], t.prototype, "radio", 2);
|
|
76
|
+
P(c, t);
|
|
12
77
|
export {
|
|
13
|
-
|
|
78
|
+
t as PieRadio,
|
|
79
|
+
p as defaultProps
|
|
14
80
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,25 +1,69 @@
|
|
|
1
|
+
import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
1
2
|
import type { CSSResult } from 'lit';
|
|
3
|
+
import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
|
|
2
4
|
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
3
5
|
import type { LitElement } from 'lit';
|
|
4
6
|
import * as React_2 from 'react';
|
|
5
7
|
import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
6
8
|
import type { TemplateResult } from 'lit-html';
|
|
7
9
|
|
|
10
|
+
export declare type DefaultProps = ComponentDefaultProps<RadioProps, keyof Omit<RadioProps, 'name' | 'value'>>;
|
|
11
|
+
|
|
12
|
+
export declare const defaultProps: DefaultProps;
|
|
13
|
+
|
|
8
14
|
export declare const PieRadio: React_2.ForwardRefExoticComponent<RadioProps & React_2.RefAttributes<PieRadio_2> & ReactBaseType>;
|
|
9
15
|
|
|
10
16
|
/**
|
|
11
17
|
* @tagname pie-radio
|
|
12
18
|
*/
|
|
13
19
|
declare class PieRadio_2 extends PieRadio_base implements RadioProps {
|
|
20
|
+
checked: boolean;
|
|
21
|
+
defaultChecked: boolean;
|
|
22
|
+
disabled: boolean;
|
|
23
|
+
name: RadioProps['name'];
|
|
24
|
+
required: boolean;
|
|
25
|
+
value: RadioProps['value'];
|
|
26
|
+
private radio;
|
|
27
|
+
/**
|
|
28
|
+
* (Read-only) returns a ValidityState with the validity states that this element is in.
|
|
29
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
|
|
30
|
+
*/
|
|
31
|
+
get validity(): ValidityState;
|
|
14
32
|
render(): TemplateResult<1>;
|
|
15
33
|
static styles: CSSResult;
|
|
16
34
|
}
|
|
17
35
|
|
|
18
|
-
declare const PieRadio_base: GenericConstructor<RTLInterface> & typeof LitElement;
|
|
36
|
+
declare const PieRadio_base: GenericConstructor<FormControlInterface> & GenericConstructor<RTLInterface> & typeof LitElement;
|
|
19
37
|
|
|
20
38
|
export declare interface RadioProps {
|
|
39
|
+
/**
|
|
40
|
+
* The checked state of the radio.
|
|
41
|
+
*/
|
|
42
|
+
checked?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The default checked state of the radio (not necessarily the same as the current checked state).
|
|
45
|
+
* Used when the radio is part of a form that is reset.
|
|
46
|
+
*/
|
|
47
|
+
defaultChecked?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Same as the HTML disabled attribute - indicates whether or not the radio is disabled.
|
|
50
|
+
*/
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The name of the radio (used as a key/value pair with `value`). This is required in order to work properly with forms.
|
|
54
|
+
*/
|
|
55
|
+
name?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Same as native required attribute. If any radio button in a same-named group of radio buttons has the required attribute,
|
|
58
|
+
* a radio button in that group must be checked, although it doesn't have to be the one with the attribute applied.
|
|
59
|
+
*/
|
|
60
|
+
required?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The value of the radio (used as a key/value pair in HTML forms with `name`).
|
|
63
|
+
*/
|
|
64
|
+
value: string;
|
|
21
65
|
}
|
|
22
66
|
|
|
23
|
-
declare type ReactBaseType = React_2.
|
|
67
|
+
declare type ReactBaseType = React_2.InputHTMLAttributes<HTMLInputElement>;
|
|
24
68
|
|
|
25
69
|
export { }
|
package/dist/react.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { createComponent as
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { createComponent as e } from "@lit/react";
|
|
3
3
|
import { PieRadio as i } from "./index.js";
|
|
4
|
+
import { defaultProps as f } from "./index.js";
|
|
4
5
|
import "lit";
|
|
6
|
+
import "lit/decorators.js";
|
|
7
|
+
import "lit/directives/if-defined.js";
|
|
8
|
+
import "lit/directives/live.js";
|
|
5
9
|
import "@justeattakeaway/pie-webc-core";
|
|
6
|
-
const
|
|
10
|
+
const t = e({
|
|
7
11
|
displayName: "PieRadio",
|
|
8
12
|
elementClass: i,
|
|
9
|
-
react:
|
|
13
|
+
react: o,
|
|
10
14
|
tagName: "pie-radio",
|
|
11
15
|
events: {}
|
|
12
|
-
}),
|
|
16
|
+
}), c = t;
|
|
13
17
|
export {
|
|
14
|
-
|
|
18
|
+
c as PieRadio,
|
|
19
|
+
f as defaultProps
|
|
15
20
|
};
|
package/package.json
CHANGED
package/src/defs-react.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Use the React IntrinsicElements interface to find how to map standard HTML elements to existing React Interfaces
|
|
5
|
-
* Example: an HTML button maps to `React.ButtonHTMLAttributes<HTMLButtonElement>`
|
|
6
|
-
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0bb210867d16170c4a08d9ce5d132817651a0f80/types/react/index.d.ts#L2829
|
|
7
|
-
*/
|
|
8
|
-
export type ReactBaseType = React.HTMLAttributes<HTMLElement>
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
|
|
3
|
+
export type ReactBaseType = React.InputHTMLAttributes<HTMLInputElement>;
|
package/src/defs.ts
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export interface RadioProps {
|
|
1
|
+
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
2
|
+
|
|
3
|
+
export interface RadioProps {
|
|
4
|
+
/**
|
|
5
|
+
* The checked state of the radio.
|
|
6
|
+
*/
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The default checked state of the radio (not necessarily the same as the current checked state).
|
|
11
|
+
* Used when the radio is part of a form that is reset.
|
|
12
|
+
*/
|
|
13
|
+
defaultChecked?: boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Same as the HTML disabled attribute - indicates whether or not the radio is disabled.
|
|
17
|
+
*/
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The name of the radio (used as a key/value pair with `value`). This is required in order to work properly with forms.
|
|
22
|
+
*/
|
|
23
|
+
name?: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Same as native required attribute. If any radio button in a same-named group of radio buttons has the required attribute,
|
|
27
|
+
* a radio button in that group must be checked, although it doesn't have to be the one with the attribute applied.
|
|
28
|
+
*/
|
|
29
|
+
required?: boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The value of the radio (used as a key/value pair in HTML forms with `name`).
|
|
33
|
+
*/
|
|
34
|
+
value: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type DefaultProps = ComponentDefaultProps<RadioProps, keyof Omit<RadioProps, 'name' | 'value'>>;
|
|
38
|
+
|
|
39
|
+
export const defaultProps: DefaultProps = {
|
|
40
|
+
checked: false,
|
|
41
|
+
defaultChecked: false,
|
|
42
|
+
disabled: false,
|
|
43
|
+
required: false,
|
|
44
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { LitElement, html, unsafeCSS } from 'lit';
|
|
2
|
-
import {
|
|
2
|
+
import { property, query } from 'lit/decorators.js';
|
|
3
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
|
+
import { live } from 'lit/directives/live.js';
|
|
5
|
+
import {
|
|
6
|
+
defineCustomElement, FormControlMixin, requiredProperty, RtlMixin,
|
|
7
|
+
} from '@justeattakeaway/pie-webc-core';
|
|
3
8
|
|
|
4
9
|
import styles from './radio.scss?inline';
|
|
5
|
-
import { RadioProps } from './defs';
|
|
10
|
+
import { type RadioProps, defaultProps } from './defs';
|
|
6
11
|
|
|
7
12
|
// Valid values available to consumers
|
|
8
13
|
export * from './defs';
|
|
@@ -12,9 +17,55 @@ const componentSelector = 'pie-radio';
|
|
|
12
17
|
/**
|
|
13
18
|
* @tagname pie-radio
|
|
14
19
|
*/
|
|
15
|
-
export class PieRadio extends RtlMixin(LitElement) implements RadioProps {
|
|
20
|
+
export class PieRadio extends FormControlMixin(RtlMixin(LitElement)) implements RadioProps {
|
|
21
|
+
@property({ type: Boolean })
|
|
22
|
+
public checked = defaultProps.checked;
|
|
23
|
+
|
|
24
|
+
@property({ type: Boolean })
|
|
25
|
+
public defaultChecked = defaultProps.defaultChecked;
|
|
26
|
+
|
|
27
|
+
@property({ type: Boolean })
|
|
28
|
+
public disabled = defaultProps.disabled;
|
|
29
|
+
|
|
30
|
+
@property({ type: String })
|
|
31
|
+
public name: RadioProps['name'];
|
|
32
|
+
|
|
33
|
+
@property({ type: Boolean })
|
|
34
|
+
public required = defaultProps.required;
|
|
35
|
+
|
|
36
|
+
@property({ type: String })
|
|
37
|
+
@requiredProperty(componentSelector)
|
|
38
|
+
public value!: RadioProps['value'];
|
|
39
|
+
|
|
40
|
+
@query('input[type="radio"]')
|
|
41
|
+
private radio!: HTMLInputElement;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* (Read-only) returns a ValidityState with the validity states that this element is in.
|
|
45
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
|
|
46
|
+
*/
|
|
47
|
+
public get validity () : ValidityState {
|
|
48
|
+
return this.radio.validity;
|
|
49
|
+
}
|
|
50
|
+
|
|
16
51
|
render () {
|
|
17
|
-
|
|
52
|
+
const {
|
|
53
|
+
checked, disabled, name, required, value,
|
|
54
|
+
} = this;
|
|
55
|
+
|
|
56
|
+
return html`
|
|
57
|
+
<input
|
|
58
|
+
type="radio"
|
|
59
|
+
id="radioId"
|
|
60
|
+
data-test-id="pie-radio"
|
|
61
|
+
.checked="${live(checked)}"
|
|
62
|
+
.value="${value}"
|
|
63
|
+
name="${ifDefined(name)}"
|
|
64
|
+
?disabled="${disabled}"
|
|
65
|
+
?required="${required}">
|
|
66
|
+
<label for="radioId">
|
|
67
|
+
<slot></slot>
|
|
68
|
+
</label>`;
|
|
18
69
|
}
|
|
19
70
|
|
|
20
71
|
// Renders a `CSSResult` generated from SCSS by Vite
|
package/src/react.ts
CHANGED
|
@@ -13,7 +13,7 @@ const PieRadioReact = createComponent({
|
|
|
13
13
|
events: {},
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
type ReactBaseType = React.
|
|
16
|
+
type ReactBaseType = React.InputHTMLAttributes<HTMLInputElement>;
|
|
17
17
|
|
|
18
18
|
export const PieRadio = PieRadioReact as React.ForwardRefExoticComponent<React.PropsWithoutRef<RadioProps>
|
|
19
19
|
& React.RefAttributes<PieRadioLit> & ReactBaseType>;
|