@toyu-ui/elements 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/LICENSE +21 -0
- package/README.md +79 -0
- package/button/tyui-button.d.ts +27 -0
- package/button.d.ts +1 -0
- package/button.js +339 -0
- package/center/tyui-center.d.ts +13 -0
- package/center.d.ts +1 -0
- package/center.js +39 -0
- package/checkbox/tyui-checkbox.d.ts +25 -0
- package/checkbox.d.ts +1 -0
- package/checkbox.js +288 -0
- package/cluster/tyui-cluster.d.ts +16 -0
- package/cluster.d.ts +1 -0
- package/cluster.js +53 -0
- package/container/tyui-container.d.ts +14 -0
- package/container.d.ts +1 -0
- package/container.js +44 -0
- package/custom-elements.json +1651 -0
- package/flex/tyui-flex.d.ts +22 -0
- package/flex.d.ts +1 -0
- package/flex.js +66 -0
- package/frame/tyui-frame.d.ts +13 -0
- package/frame.d.ts +1 -0
- package/frame.js +35 -0
- package/grid/tyui-grid.d.ts +20 -0
- package/grid.d.ts +1 -0
- package/grid.js +59 -0
- package/index.d.ts +12 -0
- package/index.js +26 -0
- package/input/tyui-input.d.ts +40 -0
- package/input.d.ts +1 -0
- package/input.js +345 -0
- package/layout/layout-helpers.d.ts +9 -0
- package/layout-helpers-C2WgKm6F.js +171 -0
- package/package.json +91 -0
- package/radio/tyui-radio.d.ts +21 -0
- package/radio-group/tyui-radio-group.d.ts +28 -0
- package/radio-group.d.ts +1 -0
- package/radio-group.js +234 -0
- package/radio.d.ts +1 -0
- package/radio.js +239 -0
- package/sidebar/tyui-sidebar.d.ts +17 -0
- package/sidebar.d.ts +1 -0
- package/sidebar.js +53 -0
- package/skills/button/SKILL.md +49 -0
- package/skills/center/SKILL.md +45 -0
- package/skills/checkbox/SKILL.md +39 -0
- package/skills/cluster/SKILL.md +44 -0
- package/skills/components/SKILL.md +53 -0
- package/skills/container/SKILL.md +42 -0
- package/skills/flex/SKILL.md +45 -0
- package/skills/frame/SKILL.md +42 -0
- package/skills/grid/SKILL.md +44 -0
- package/skills/input/SKILL.md +59 -0
- package/skills/radio/SKILL.md +49 -0
- package/skills/radio-group/SKILL.md +51 -0
- package/skills/sidebar/SKILL.md +43 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
const a = new CSSStyleSheet(), n = `
|
|
2
|
+
@layer reset, tokens, product-theme, components, product-components, utilities, overrides;
|
|
3
|
+
|
|
4
|
+
@layer utilities {
|
|
5
|
+
.ty-flex,
|
|
6
|
+
tyui-flex {
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
display: var(--ty-flex-display, flex);
|
|
9
|
+
flex-direction: var(--ty-flex-direction, row);
|
|
10
|
+
flex-wrap: var(--ty-flex-wrap, nowrap);
|
|
11
|
+
align-items: var(--ty-flex-align, stretch);
|
|
12
|
+
justify-content: var(--ty-flex-justify, flex-start);
|
|
13
|
+
gap: var(--ty-flex-gap, var(--ty-layout-gap, var(--ty-space-3, 0.75rem)));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ty-cluster,
|
|
17
|
+
tyui-cluster {
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-wrap: wrap;
|
|
21
|
+
align-items: var(--ty-cluster-align, center);
|
|
22
|
+
justify-content: var(--ty-cluster-justify, flex-start);
|
|
23
|
+
gap:
|
|
24
|
+
var(--ty-cluster-row-gap, var(--ty-cluster-gap, var(--ty-space-2, 0.5rem)))
|
|
25
|
+
var(--ty-cluster-gap, var(--ty-space-2, 0.5rem));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ty-grid,
|
|
29
|
+
tyui-grid {
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
display: grid;
|
|
32
|
+
grid-template-columns: repeat(
|
|
33
|
+
auto-fit,
|
|
34
|
+
minmax(min(100%, var(--ty-grid-min-item-size, 16rem)), 1fr)
|
|
35
|
+
);
|
|
36
|
+
align-items: var(--ty-grid-align, stretch);
|
|
37
|
+
justify-items: var(--ty-grid-justify, stretch);
|
|
38
|
+
grid-auto-flow: var(--ty-grid-auto-flow, row);
|
|
39
|
+
gap:
|
|
40
|
+
var(--ty-grid-row-gap, var(--ty-grid-gap, var(--ty-space-4, 1rem)))
|
|
41
|
+
var(--ty-grid-gap, var(--ty-space-4, 1rem));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.ty-center,
|
|
45
|
+
tyui-center {
|
|
46
|
+
box-sizing: content-box;
|
|
47
|
+
display: var(--ty-center-display, block);
|
|
48
|
+
margin-inline: auto;
|
|
49
|
+
max-inline-size: var(--ty-center-measure, var(--ty-layout-content-measure, 65ch));
|
|
50
|
+
padding-inline: var(--ty-center-gutter, var(--ty-page-gutter, 1rem));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
tyui-center[intrinsic],
|
|
54
|
+
.ty-center[data-intrinsic='true'] {
|
|
55
|
+
--ty-center-display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
align-items: center;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.ty-container,
|
|
61
|
+
tyui-container {
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
display: block;
|
|
64
|
+
inline-size: 100%;
|
|
65
|
+
max-inline-size: var(--ty-container-max-inline-size, var(--ty-container-wide, 72rem));
|
|
66
|
+
margin-inline: auto;
|
|
67
|
+
padding-inline: var(--ty-container-gutter, var(--ty-page-gutter, 1rem));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
tyui-container[bleed],
|
|
71
|
+
.ty-container[data-bleed='true'] {
|
|
72
|
+
max-inline-size: none;
|
|
73
|
+
padding-inline: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.ty-frame,
|
|
77
|
+
tyui-frame {
|
|
78
|
+
box-sizing: border-box;
|
|
79
|
+
aspect-ratio: var(--ty-frame-ratio, 16 / 9);
|
|
80
|
+
display: block;
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.ty-frame > *,
|
|
85
|
+
tyui-frame > * {
|
|
86
|
+
box-sizing: border-box;
|
|
87
|
+
block-size: 100%;
|
|
88
|
+
inline-size: 100%;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.ty-frame > img,
|
|
92
|
+
.ty-frame > video,
|
|
93
|
+
.ty-frame > iframe,
|
|
94
|
+
.ty-frame > canvas,
|
|
95
|
+
tyui-frame > img,
|
|
96
|
+
tyui-frame > video,
|
|
97
|
+
tyui-frame > iframe,
|
|
98
|
+
tyui-frame > canvas {
|
|
99
|
+
object-fit: var(--ty-frame-fit, cover);
|
|
100
|
+
object-position: var(--ty-frame-position, center);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.ty-sidebar,
|
|
104
|
+
tyui-sidebar {
|
|
105
|
+
box-sizing: border-box;
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-direction: var(--ty-sidebar-direction, row);
|
|
108
|
+
flex-wrap: wrap;
|
|
109
|
+
align-items: var(--ty-sidebar-align, stretch);
|
|
110
|
+
gap: var(--ty-sidebar-gap, var(--ty-layout-gap, var(--ty-space-3, 0.75rem)));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.ty-sidebar > :first-child,
|
|
114
|
+
tyui-sidebar > :first-child {
|
|
115
|
+
flex-basis: var(--ty-sidebar-size, 18rem);
|
|
116
|
+
flex-grow: 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.ty-sidebar > :last-child,
|
|
120
|
+
tyui-sidebar > :last-child {
|
|
121
|
+
flex-basis: 0;
|
|
122
|
+
flex-grow: 999;
|
|
123
|
+
min-inline-size: min(100%, var(--ty-sidebar-content-min-inline-size, 50%));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
a.replaceSync(n);
|
|
128
|
+
let i = !1;
|
|
129
|
+
function o() {
|
|
130
|
+
i || typeof document > "u" || (document.adoptedStyleSheets = [...document.adoptedStyleSheets, a], i = !0);
|
|
131
|
+
}
|
|
132
|
+
function s(e, r, t) {
|
|
133
|
+
return r.includes(e) ? e : t;
|
|
134
|
+
}
|
|
135
|
+
function y(e, r, t) {
|
|
136
|
+
if (typeof t == "boolean") {
|
|
137
|
+
e.toggleAttribute(r, t);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
e.setAttribute(r, t);
|
|
141
|
+
}
|
|
142
|
+
function c(e, r) {
|
|
143
|
+
const t = s(e, ["0", "1", "2", "3", "4"], r);
|
|
144
|
+
return `var(--ty-space-${t}, ${{
|
|
145
|
+
0: "0",
|
|
146
|
+
1: "0.25rem",
|
|
147
|
+
2: "0.5rem",
|
|
148
|
+
3: "0.75rem",
|
|
149
|
+
4: "1rem"
|
|
150
|
+
}[t]})`;
|
|
151
|
+
}
|
|
152
|
+
function d(e, r) {
|
|
153
|
+
const t = e?.trim();
|
|
154
|
+
return t || r;
|
|
155
|
+
}
|
|
156
|
+
function u(e, r) {
|
|
157
|
+
const t = e?.trim();
|
|
158
|
+
return t ? t.replace("/", " / ") : r;
|
|
159
|
+
}
|
|
160
|
+
function f(e, r, t) {
|
|
161
|
+
e.style.setProperty(r, t);
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
f as a,
|
|
165
|
+
c as b,
|
|
166
|
+
o as i,
|
|
167
|
+
d as l,
|
|
168
|
+
s as n,
|
|
169
|
+
u as r,
|
|
170
|
+
y as s
|
|
171
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@toyu-ui/elements",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"tanstack-intent"
|
|
6
|
+
],
|
|
7
|
+
"homepage": "https://github.com/jurokapsiar/tyui#readme",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/jurokapsiar/tyui/issues"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/jurokapsiar/tyui.git",
|
|
15
|
+
"directory": "libs/elements"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"main": "./index.js",
|
|
20
|
+
"module": "./index.js",
|
|
21
|
+
"types": "./index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./index.d.ts",
|
|
25
|
+
"default": "./index.js"
|
|
26
|
+
},
|
|
27
|
+
"./button": {
|
|
28
|
+
"types": "./button.d.ts",
|
|
29
|
+
"default": "./button.js"
|
|
30
|
+
},
|
|
31
|
+
"./center": {
|
|
32
|
+
"types": "./center.d.ts",
|
|
33
|
+
"default": "./center.js"
|
|
34
|
+
},
|
|
35
|
+
"./checkbox": {
|
|
36
|
+
"types": "./checkbox.d.ts",
|
|
37
|
+
"default": "./checkbox.js"
|
|
38
|
+
},
|
|
39
|
+
"./cluster": {
|
|
40
|
+
"types": "./cluster.d.ts",
|
|
41
|
+
"default": "./cluster.js"
|
|
42
|
+
},
|
|
43
|
+
"./container": {
|
|
44
|
+
"types": "./container.d.ts",
|
|
45
|
+
"default": "./container.js"
|
|
46
|
+
},
|
|
47
|
+
"./flex": {
|
|
48
|
+
"types": "./flex.d.ts",
|
|
49
|
+
"default": "./flex.js"
|
|
50
|
+
},
|
|
51
|
+
"./frame": {
|
|
52
|
+
"types": "./frame.d.ts",
|
|
53
|
+
"default": "./frame.js"
|
|
54
|
+
},
|
|
55
|
+
"./grid": {
|
|
56
|
+
"types": "./grid.d.ts",
|
|
57
|
+
"default": "./grid.js"
|
|
58
|
+
},
|
|
59
|
+
"./input": {
|
|
60
|
+
"types": "./input.d.ts",
|
|
61
|
+
"default": "./input.js"
|
|
62
|
+
},
|
|
63
|
+
"./radio": {
|
|
64
|
+
"types": "./radio.d.ts",
|
|
65
|
+
"default": "./radio.js"
|
|
66
|
+
},
|
|
67
|
+
"./radio-group": {
|
|
68
|
+
"types": "./radio-group.d.ts",
|
|
69
|
+
"default": "./radio-group.js"
|
|
70
|
+
},
|
|
71
|
+
"./sidebar": {
|
|
72
|
+
"types": "./sidebar.d.ts",
|
|
73
|
+
"default": "./sidebar.js"
|
|
74
|
+
},
|
|
75
|
+
"./custom-elements.json": {
|
|
76
|
+
"default": "./custom-elements.json"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"publishConfig": {
|
|
80
|
+
"access": "public"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "vite build",
|
|
84
|
+
"test": "vitest run --passWithNoTests",
|
|
85
|
+
"typecheck": "tsc -p tsconfig.lib.json --noEmit"
|
|
86
|
+
},
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"@toyu-ui/core": "^0.1.0"
|
|
89
|
+
},
|
|
90
|
+
"private": false
|
|
91
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type TyuiRadioLabelPosition = 'after' | 'below';
|
|
2
|
+
export declare class TyuiRadioElement extends HTMLElement {
|
|
3
|
+
#private;
|
|
4
|
+
static observedAttributes: string[];
|
|
5
|
+
constructor();
|
|
6
|
+
get checked(): boolean;
|
|
7
|
+
set checked(value: boolean);
|
|
8
|
+
get disabled(): boolean;
|
|
9
|
+
set disabled(value: boolean);
|
|
10
|
+
get labelPosition(): TyuiRadioLabelPosition;
|
|
11
|
+
set labelPosition(value: TyuiRadioLabelPosition);
|
|
12
|
+
get name(): string;
|
|
13
|
+
set name(value: string);
|
|
14
|
+
get required(): boolean;
|
|
15
|
+
set required(value: boolean);
|
|
16
|
+
get value(): string;
|
|
17
|
+
set value(value: string);
|
|
18
|
+
connectedCallback(): void;
|
|
19
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
20
|
+
focus(options?: FocusOptions): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type TyuiRadioGroupLayout = 'vertical' | 'horizontal' | 'horizontal-stacked';
|
|
2
|
+
export type TyuiRadioGroupEventDetail = {
|
|
3
|
+
value: string;
|
|
4
|
+
};
|
|
5
|
+
export type TyuiRadioGroupEvent = CustomEvent<TyuiRadioGroupEventDetail>;
|
|
6
|
+
export declare class TyuiRadioGroupElement extends HTMLElement {
|
|
7
|
+
#private;
|
|
8
|
+
static formAssociated: boolean;
|
|
9
|
+
static observedAttributes: string[];
|
|
10
|
+
constructor();
|
|
11
|
+
get disabled(): boolean;
|
|
12
|
+
set disabled(value: boolean);
|
|
13
|
+
get label(): string;
|
|
14
|
+
set label(value: string);
|
|
15
|
+
get layout(): TyuiRadioGroupLayout;
|
|
16
|
+
set layout(value: TyuiRadioGroupLayout);
|
|
17
|
+
get name(): string;
|
|
18
|
+
set name(value: string);
|
|
19
|
+
get required(): boolean;
|
|
20
|
+
set required(value: boolean);
|
|
21
|
+
get value(): string;
|
|
22
|
+
set value(value: string);
|
|
23
|
+
get validity(): ValidityState | undefined;
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
26
|
+
checkValidity(): boolean;
|
|
27
|
+
reportValidity(): boolean;
|
|
28
|
+
}
|
package/radio-group.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './radio-group/tyui-radio-group';
|
package/radio-group.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
const o = new CSSStyleSheet();
|
|
2
|
+
o.replaceSync(`
|
|
3
|
+
@layer ty.component-base {
|
|
4
|
+
:host {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: var(--ty-radio-group-gap, var(--ty-space-2, 0.5rem));
|
|
8
|
+
color: var(--ty-radio-group-foreground, var(--ty-color-text, CanvasText));
|
|
9
|
+
font-family: var(--ty-font-family, inherit);
|
|
10
|
+
font-size: var(--ty-radio-group-font-size, var(--ty-control-font-size, 0.875rem));
|
|
11
|
+
line-height: var(--ty-radio-group-line-height, 1.25rem);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:host([disabled]) {
|
|
15
|
+
color: var(--ty-radio-group-disabled-foreground, var(--ty-color-disabled-text, GrayText));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
[part='label'] {
|
|
19
|
+
color: var(--ty-radio-group-label-color, currentColor);
|
|
20
|
+
font-weight: var(--ty-radio-group-label-font-weight, var(--ty-font-weight-regular, 400));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[part='items'] {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
gap: var(--ty-radio-group-gap, var(--ty-space-2, 0.5rem));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:host([layout='horizontal']) [part='items'],
|
|
30
|
+
:host([layout='horizontal-stacked']) [part='items'] {
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
align-items: center;
|
|
34
|
+
gap: var(--ty-radio-group-inline-gap, var(--ty-space-4, 1rem));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:host([layout='horizontal-stacked']) [part='items'] {
|
|
38
|
+
align-items: flex-start;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@media (forced-colors: active) {
|
|
42
|
+
:host,
|
|
43
|
+
[part='label'] {
|
|
44
|
+
color: CanvasText;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:host([disabled]),
|
|
48
|
+
:host([disabled]) [part='label'] {
|
|
49
|
+
color: GrayText;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`);
|
|
54
|
+
const n = document.createElement("template");
|
|
55
|
+
n.innerHTML = `
|
|
56
|
+
<span part="label"></span>
|
|
57
|
+
<div part="items"><slot></slot></div>
|
|
58
|
+
`;
|
|
59
|
+
let h = 0, d = 0;
|
|
60
|
+
function u(s) {
|
|
61
|
+
return s === "horizontal" || s === "horizontal-stacked" ? s : "vertical";
|
|
62
|
+
}
|
|
63
|
+
function l(s, t) {
|
|
64
|
+
return s.hasAttribute(t);
|
|
65
|
+
}
|
|
66
|
+
class c extends HTMLElement {
|
|
67
|
+
static formAssociated = !0;
|
|
68
|
+
static observedAttributes = ["disabled", "label", "layout", "name", "required", "value"];
|
|
69
|
+
#r;
|
|
70
|
+
#s;
|
|
71
|
+
#n;
|
|
72
|
+
#d = `tyui-radio-group-label-${++h}`;
|
|
73
|
+
#b = `tyui-radio-group-${++d}`;
|
|
74
|
+
#h = !1;
|
|
75
|
+
#e = "";
|
|
76
|
+
#i = "";
|
|
77
|
+
#t = "";
|
|
78
|
+
constructor() {
|
|
79
|
+
super();
|
|
80
|
+
const t = this.attachShadow({ mode: "open" });
|
|
81
|
+
t.adoptedStyleSheets = [o], t.append(n.content.cloneNode(!0));
|
|
82
|
+
const e = t.querySelector('[part="label"]'), i = t.querySelector("slot");
|
|
83
|
+
if (!(e instanceof HTMLElement) || !(i instanceof HTMLSlotElement))
|
|
84
|
+
throw new Error("TyuiRadioGroupElement template is missing expected nodes.");
|
|
85
|
+
this.#s = e, this.#n = i, this.#r = this.#f(), this.addEventListener("click", this.#m), this.addEventListener("keydown", this.#A), this.#n.addEventListener("slotchange", this.#p);
|
|
86
|
+
}
|
|
87
|
+
get disabled() {
|
|
88
|
+
return l(this, "disabled");
|
|
89
|
+
}
|
|
90
|
+
set disabled(t) {
|
|
91
|
+
this.toggleAttribute("disabled", t);
|
|
92
|
+
}
|
|
93
|
+
get label() {
|
|
94
|
+
return this.#e;
|
|
95
|
+
}
|
|
96
|
+
set label(t) {
|
|
97
|
+
this.#e = String(t), this.#e ? this.setAttribute("label", this.#e) : this.removeAttribute("label");
|
|
98
|
+
}
|
|
99
|
+
get layout() {
|
|
100
|
+
return u(this.getAttribute("layout"));
|
|
101
|
+
}
|
|
102
|
+
set layout(t) {
|
|
103
|
+
this.setAttribute("layout", t);
|
|
104
|
+
}
|
|
105
|
+
get name() {
|
|
106
|
+
return this.#i;
|
|
107
|
+
}
|
|
108
|
+
set name(t) {
|
|
109
|
+
this.#i = String(t), this.#i ? this.setAttribute("name", this.#i) : this.removeAttribute("name");
|
|
110
|
+
}
|
|
111
|
+
get required() {
|
|
112
|
+
return l(this, "required");
|
|
113
|
+
}
|
|
114
|
+
set required(t) {
|
|
115
|
+
this.toggleAttribute("required", t);
|
|
116
|
+
}
|
|
117
|
+
get value() {
|
|
118
|
+
return this.#t;
|
|
119
|
+
}
|
|
120
|
+
set value(t) {
|
|
121
|
+
this.#a(String(t), !1);
|
|
122
|
+
}
|
|
123
|
+
get validity() {
|
|
124
|
+
return this.#r?.validity;
|
|
125
|
+
}
|
|
126
|
+
connectedCallback() {
|
|
127
|
+
this.#g(), this.hasAttribute("role") || this.setAttribute("role", "radiogroup"), this.getAttribute("aria-labelledby") ? this.#h = !0 : this.setAttribute("aria-labelledby", this.#d), this.#y(), this.#l();
|
|
128
|
+
}
|
|
129
|
+
attributeChangedCallback(t, e, i) {
|
|
130
|
+
t === "label" ? this.#e = i ?? "" : t === "name" ? this.#i = i ?? "" : t === "value" && (this.#t = i ?? ""), this.#l();
|
|
131
|
+
}
|
|
132
|
+
checkValidity() {
|
|
133
|
+
return this.#r?.checkValidity() ?? (!this.required || !!this.#t || this.disabled);
|
|
134
|
+
}
|
|
135
|
+
reportValidity() {
|
|
136
|
+
return this.#r?.reportValidity() ?? this.checkValidity();
|
|
137
|
+
}
|
|
138
|
+
#f() {
|
|
139
|
+
if (!("attachInternals" in this)) return null;
|
|
140
|
+
try {
|
|
141
|
+
return this.attachInternals();
|
|
142
|
+
} catch {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
#g() {
|
|
147
|
+
this.#e = this.getAttribute("label") ?? this.#e, this.#i = this.getAttribute("name") ?? this.#i, this.#t = this.getAttribute("value") ?? this.#t;
|
|
148
|
+
}
|
|
149
|
+
#y() {
|
|
150
|
+
this.hasAttribute("layout") || this.setAttribute("layout", "vertical");
|
|
151
|
+
}
|
|
152
|
+
#p = () => {
|
|
153
|
+
if (!this.#t) {
|
|
154
|
+
const t = this.#o().find((e) => e.checked);
|
|
155
|
+
t && (this.#t = t.value);
|
|
156
|
+
}
|
|
157
|
+
this.#l();
|
|
158
|
+
};
|
|
159
|
+
#m = (t) => {
|
|
160
|
+
if (this.disabled) return;
|
|
161
|
+
const e = this.#c(t.composedPath());
|
|
162
|
+
!e || e.disabled || e.getAttribute("aria-disabled") === "true" || this.#a(e.value, !0);
|
|
163
|
+
};
|
|
164
|
+
#A = (t) => {
|
|
165
|
+
if (this.disabled) return;
|
|
166
|
+
const e = this.#S();
|
|
167
|
+
if (e.length === 0) return;
|
|
168
|
+
const i = this.#c(t.composedPath()), r = i ? e.indexOf(i) : -1;
|
|
169
|
+
if (t.key === "ArrowDown" || t.key === "ArrowRight") {
|
|
170
|
+
t.preventDefault();
|
|
171
|
+
const a = e[r === -1 ? 0 : (r + 1) % e.length];
|
|
172
|
+
a && this.#u(a);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (t.key === "ArrowUp" || t.key === "ArrowLeft") {
|
|
176
|
+
t.preventDefault();
|
|
177
|
+
const a = e[r === -1 ? 0 : (r - 1 + e.length) % e.length];
|
|
178
|
+
a && this.#u(a);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
t.key === " " && i && !i.disabled && (t.preventDefault(), this.#a(i.value, !0));
|
|
182
|
+
};
|
|
183
|
+
#u(t) {
|
|
184
|
+
this.#a(t.value, !0), t.focus();
|
|
185
|
+
}
|
|
186
|
+
#a(t, e) {
|
|
187
|
+
t !== this.#t && (this.#t = t, t ? this.setAttribute("value", t) : this.removeAttribute("value"), this.#l(), e && this.dispatchEvent(
|
|
188
|
+
new CustomEvent("change", {
|
|
189
|
+
detail: { value: this.#t },
|
|
190
|
+
bubbles: !0,
|
|
191
|
+
composed: !0
|
|
192
|
+
})
|
|
193
|
+
));
|
|
194
|
+
}
|
|
195
|
+
#l() {
|
|
196
|
+
this.setAttribute("aria-disabled", String(this.disabled)), this.setAttribute("aria-required", String(this.required)), this.#s.id = this.#d, this.#s.textContent = this.#h ? "" : this.#e, this.#s.toggleAttribute("hidden", this.#h && this.#e.length === 0), this.#v(), this.#k();
|
|
197
|
+
}
|
|
198
|
+
#v() {
|
|
199
|
+
const t = this.#o(), e = this.layout === "horizontal-stacked" ? "below" : "after";
|
|
200
|
+
for (const i of t)
|
|
201
|
+
this.#t && i.toggleAttribute("checked", i.value === this.#t), i.toggleAttribute("required", this.required), i.setAttribute("label-position", e), this.#i ? i.setAttribute("name", this.#i) : i.name || i.setAttribute("name", this.#b), this.disabled ? (i.setAttribute("aria-disabled", "true"), i.tabIndex = -1) : i.setAttribute("aria-disabled", String(i.disabled));
|
|
202
|
+
this.#x(t);
|
|
203
|
+
}
|
|
204
|
+
#x(t = this.#o()) {
|
|
205
|
+
if (this.disabled) {
|
|
206
|
+
for (const r of t) r.tabIndex = -1;
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const i = t.find((r) => r.checked && !r.disabled) ?? t.find((r) => !r.disabled);
|
|
210
|
+
for (const r of t)
|
|
211
|
+
r.tabIndex = r === i ? 0 : -1;
|
|
212
|
+
}
|
|
213
|
+
#k() {
|
|
214
|
+
if (this.#r?.setFormValue(!this.disabled && this.#t ? this.#t : null), this.required && !this.disabled && !this.#t) {
|
|
215
|
+
this.#r?.setValidity({ valueMissing: !0 }, "Select an option.");
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this.#r?.setValidity({});
|
|
219
|
+
}
|
|
220
|
+
#o() {
|
|
221
|
+
return this.#n.assignedElements({ flatten: !0 }).filter((t) => t.tagName === "TYUI-RADIO");
|
|
222
|
+
}
|
|
223
|
+
#S() {
|
|
224
|
+
return this.#o().filter((t) => !t.disabled);
|
|
225
|
+
}
|
|
226
|
+
#c(t) {
|
|
227
|
+
return t.find(
|
|
228
|
+
(e) => e instanceof Element && e.tagName === "TYUI-RADIO"
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
export {
|
|
233
|
+
c as TyuiRadioGroupElement
|
|
234
|
+
};
|
package/radio.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './radio/tyui-radio';
|