@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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +79 -0
  3. package/button/tyui-button.d.ts +27 -0
  4. package/button.d.ts +1 -0
  5. package/button.js +339 -0
  6. package/center/tyui-center.d.ts +13 -0
  7. package/center.d.ts +1 -0
  8. package/center.js +39 -0
  9. package/checkbox/tyui-checkbox.d.ts +25 -0
  10. package/checkbox.d.ts +1 -0
  11. package/checkbox.js +288 -0
  12. package/cluster/tyui-cluster.d.ts +16 -0
  13. package/cluster.d.ts +1 -0
  14. package/cluster.js +53 -0
  15. package/container/tyui-container.d.ts +14 -0
  16. package/container.d.ts +1 -0
  17. package/container.js +44 -0
  18. package/custom-elements.json +1651 -0
  19. package/flex/tyui-flex.d.ts +22 -0
  20. package/flex.d.ts +1 -0
  21. package/flex.js +66 -0
  22. package/frame/tyui-frame.d.ts +13 -0
  23. package/frame.d.ts +1 -0
  24. package/frame.js +35 -0
  25. package/grid/tyui-grid.d.ts +20 -0
  26. package/grid.d.ts +1 -0
  27. package/grid.js +59 -0
  28. package/index.d.ts +12 -0
  29. package/index.js +26 -0
  30. package/input/tyui-input.d.ts +40 -0
  31. package/input.d.ts +1 -0
  32. package/input.js +345 -0
  33. package/layout/layout-helpers.d.ts +9 -0
  34. package/layout-helpers-C2WgKm6F.js +171 -0
  35. package/package.json +91 -0
  36. package/radio/tyui-radio.d.ts +21 -0
  37. package/radio-group/tyui-radio-group.d.ts +28 -0
  38. package/radio-group.d.ts +1 -0
  39. package/radio-group.js +234 -0
  40. package/radio.d.ts +1 -0
  41. package/radio.js +239 -0
  42. package/sidebar/tyui-sidebar.d.ts +17 -0
  43. package/sidebar.d.ts +1 -0
  44. package/sidebar.js +53 -0
  45. package/skills/button/SKILL.md +49 -0
  46. package/skills/center/SKILL.md +45 -0
  47. package/skills/checkbox/SKILL.md +39 -0
  48. package/skills/cluster/SKILL.md +44 -0
  49. package/skills/components/SKILL.md +53 -0
  50. package/skills/container/SKILL.md +42 -0
  51. package/skills/flex/SKILL.md +45 -0
  52. package/skills/frame/SKILL.md +42 -0
  53. package/skills/grid/SKILL.md +44 -0
  54. package/skills/input/SKILL.md +59 -0
  55. package/skills/radio/SKILL.md +49 -0
  56. package/skills/radio-group/SKILL.md +51 -0
  57. package/skills/sidebar/SKILL.md +43 -0
package/checkbox.js ADDED
@@ -0,0 +1,288 @@
1
+ const a = new CSSStyleSheet();
2
+ a.replaceSync(`
3
+ @layer ty.component-base {
4
+ :host {
5
+ display: inline-flex;
6
+ align-items: center;
7
+ color: var(--ty-checkbox-foreground, var(--ty-color-text, CanvasText));
8
+ font-family: var(--ty-font-family, inherit);
9
+ font-size: var(--ty-checkbox-font-size, var(--ty-control-font-size, 0.875rem));
10
+ line-height: var(--ty-checkbox-line-height, 1.25rem);
11
+ cursor: pointer;
12
+ user-select: none;
13
+ -webkit-tap-highlight-color: transparent;
14
+ }
15
+
16
+ :host([disabled]) {
17
+ color: var(--ty-checkbox-disabled-foreground, var(--ty-color-disabled-text, GrayText));
18
+ cursor: not-allowed;
19
+ }
20
+
21
+ [part='control'] {
22
+ display: inline-flex;
23
+ align-items: center;
24
+ gap: var(--ty-checkbox-gap, var(--ty-control-gap, 0.5rem));
25
+ cursor: inherit;
26
+ }
27
+
28
+ input[type='checkbox'] {
29
+ position: absolute;
30
+ inline-size: 1px;
31
+ block-size: 1px;
32
+ margin: -1px;
33
+ padding: 0;
34
+ overflow: hidden;
35
+ clip: rect(0 0 0 0);
36
+ clip-path: inset(50%);
37
+ white-space: nowrap;
38
+ border: 0;
39
+ }
40
+
41
+ [part='box'] {
42
+ box-sizing: border-box;
43
+ display: inline-flex;
44
+ flex: none;
45
+ align-items: center;
46
+ justify-content: center;
47
+ inline-size: var(--ty-checkbox-size, 1rem);
48
+ block-size: var(--ty-checkbox-size, 1rem);
49
+ border:
50
+ var(--ty-checkbox-border-width, var(--ty-control-border-width, 1px))
51
+ solid
52
+ var(--ty-checkbox-border-color, var(--ty-color-border-strong, ButtonText));
53
+ border-radius: var(--ty-checkbox-radius, var(--ty-radius-1, 0.25rem));
54
+ background: var(--ty-checkbox-background, var(--ty-color-surface, Canvas));
55
+ color: var(--ty-checkbox-mark-color, transparent);
56
+ transition:
57
+ background-color var(--ty-motion-feedback-duration, 120ms) var(--ty-motion-easing, ease),
58
+ border-color var(--ty-motion-feedback-duration, 120ms) var(--ty-motion-easing, ease),
59
+ color var(--ty-motion-feedback-duration, 120ms) var(--ty-motion-easing, ease),
60
+ box-shadow var(--ty-motion-feedback-duration, 120ms) var(--ty-motion-easing, ease);
61
+ }
62
+
63
+ :host(:hover:not([disabled]):not([checked]):not([indeterminate])) [part='box'] {
64
+ border-color: var(--ty-checkbox-border-color-hover, var(--ty-color-border-strong, ButtonText));
65
+ }
66
+
67
+ :host([checked]) [part='box'] {
68
+ --ty-checkbox-mark-color: var(--ty-checkbox-checked-foreground, var(--ty-color-on-accent, HighlightText));
69
+ background: var(--ty-checkbox-checked-background, var(--ty-color-accent, Highlight));
70
+ border-color: var(--ty-checkbox-checked-border-color, var(--ty-color-accent, Highlight));
71
+ }
72
+
73
+ :host([indeterminate]) [part='box'] {
74
+ --ty-checkbox-mark-color: var(--ty-checkbox-indeterminate-foreground, var(--ty-color-accent, Highlight));
75
+ background: var(--ty-checkbox-background, var(--ty-color-surface, Canvas));
76
+ border-color: var(--ty-checkbox-indeterminate-border-color, var(--ty-color-accent, Highlight));
77
+ }
78
+
79
+ :host(:hover:not([disabled])[checked]) [part='box'] {
80
+ background: var(--ty-checkbox-checked-background-hover, var(--ty-color-accent-hover, Highlight));
81
+ border-color: var(--ty-checkbox-checked-border-color-hover, var(--ty-color-accent-hover, Highlight));
82
+ }
83
+
84
+ :host(:active:not([disabled])[checked]) [part='box'] {
85
+ background: var(--ty-checkbox-checked-background-active, var(--ty-color-accent-pressed, Highlight));
86
+ border-color: var(--ty-checkbox-checked-border-color-active, var(--ty-color-accent-pressed, Highlight));
87
+ }
88
+
89
+ :host([disabled]) [part='box'] {
90
+ background: var(--ty-checkbox-disabled-background, var(--ty-color-disabled-surface, Canvas));
91
+ border-color: var(--ty-checkbox-disabled-border-color, var(--ty-color-disabled-border, GrayText));
92
+ }
93
+
94
+ :host([disabled][checked]) [part='box'],
95
+ :host([disabled][indeterminate]) [part='box'] {
96
+ --ty-checkbox-mark-color: var(--ty-checkbox-disabled-foreground, var(--ty-color-disabled-text, GrayText));
97
+ background: var(--ty-checkbox-disabled-selected-background, var(--ty-color-disabled-border, GrayText));
98
+ border-color: var(--ty-checkbox-disabled-border-color, var(--ty-color-disabled-border, GrayText));
99
+ }
100
+
101
+ [data-ty-checkbox-mark] {
102
+ inline-size: calc(var(--ty-checkbox-size, 1rem) * 0.75);
103
+ block-size: calc(var(--ty-checkbox-size, 1rem) * 0.75);
104
+ color: inherit;
105
+ }
106
+
107
+ [part='label'] {
108
+ min-inline-size: 0;
109
+ }
110
+
111
+ :host(:focus-within) [part='box'] {
112
+ outline: var(--ty-focus-width, 2px) solid var(--ty-focus-color, Highlight);
113
+ outline-offset: var(--ty-focus-offset, 2px);
114
+ box-shadow: 0 0 0 2px var(--ty-focus-inner-color, Canvas);
115
+ }
116
+
117
+ @media (forced-colors: active) {
118
+ [part='box'] {
119
+ forced-color-adjust: none;
120
+ background: ButtonFace;
121
+ border-color: ButtonText;
122
+ }
123
+
124
+ :host([checked]) [part='box'],
125
+ :host([indeterminate]) [part='box'] {
126
+ background: Highlight;
127
+ border-color: Highlight;
128
+ color: HighlightText;
129
+ }
130
+
131
+ :host([disabled]) {
132
+ color: GrayText;
133
+ }
134
+
135
+ :host([disabled]) [part='box'] {
136
+ border-color: GrayText;
137
+ }
138
+ }
139
+
140
+ @media (prefers-reduced-motion: reduce) {
141
+ [part='box'] {
142
+ transition-duration: 0ms;
143
+ }
144
+ }
145
+ }
146
+ `);
147
+ const c = document.createElement("template");
148
+ c.innerHTML = `
149
+ <label part="control">
150
+ <input type="checkbox" />
151
+ <span part="box" aria-hidden="true"></span>
152
+ <span part="label"><slot></slot></span>
153
+ </label>
154
+ `;
155
+ function i(o, e) {
156
+ return o.hasAttribute(e);
157
+ }
158
+ class s extends HTMLElement {
159
+ static formAssociated = !0;
160
+ static observedAttributes = ["checked", "disabled", "indeterminate", "name", "required", "value"];
161
+ #e;
162
+ #o;
163
+ #i;
164
+ #t = "";
165
+ #r = "on";
166
+ constructor() {
167
+ super();
168
+ const e = this.attachShadow({ mode: "open", delegatesFocus: !0 });
169
+ e.adoptedStyleSheets = [a], e.append(c.content.cloneNode(!0));
170
+ const t = e.querySelector("input"), r = e.querySelector('[part="box"]');
171
+ if (!(t instanceof HTMLInputElement) || !(r instanceof HTMLElement))
172
+ throw new Error("TyuiCheckboxElement template is missing expected controls.");
173
+ this.#e = t, this.#o = r, this.#i = this.#s(), this.addEventListener("click", this.#d, { capture: !0 }), this.addEventListener("keydown", this.#h), this.#e.addEventListener("change", this.#l);
174
+ }
175
+ get checked() {
176
+ return i(this, "checked");
177
+ }
178
+ set checked(e) {
179
+ this.toggleAttribute("checked", e);
180
+ }
181
+ get disabled() {
182
+ return i(this, "disabled");
183
+ }
184
+ set disabled(e) {
185
+ this.toggleAttribute("disabled", e);
186
+ }
187
+ get indeterminate() {
188
+ return i(this, "indeterminate");
189
+ }
190
+ set indeterminate(e) {
191
+ this.toggleAttribute("indeterminate", e);
192
+ }
193
+ get name() {
194
+ return this.#t;
195
+ }
196
+ set name(e) {
197
+ this.#t = String(e), this.#t ? this.setAttribute("name", this.#t) : this.removeAttribute("name");
198
+ }
199
+ get required() {
200
+ return i(this, "required");
201
+ }
202
+ set required(e) {
203
+ this.toggleAttribute("required", e);
204
+ }
205
+ get value() {
206
+ return this.#r;
207
+ }
208
+ set value(e) {
209
+ this.#r = String(e), this.setAttribute("value", this.#r);
210
+ }
211
+ get validity() {
212
+ return this.#i?.validity ?? this.#e.validity;
213
+ }
214
+ connectedCallback() {
215
+ this.#n(), this.hasAttribute("tabindex") || (this.tabIndex = this.disabled ? -1 : 0), this.#c();
216
+ }
217
+ attributeChangedCallback(e, t, r) {
218
+ e === "name" ? this.#t = r ?? "" : e === "value" && (this.#r = r ?? "on"), this.#c();
219
+ }
220
+ focus(e) {
221
+ this.#e.focus(e);
222
+ }
223
+ checkValidity() {
224
+ return this.#i?.checkValidity() ?? this.#e.checkValidity();
225
+ }
226
+ reportValidity() {
227
+ return this.#i?.reportValidity() ?? this.#e.reportValidity();
228
+ }
229
+ #s() {
230
+ if (!("attachInternals" in this)) return null;
231
+ try {
232
+ return this.attachInternals();
233
+ } catch {
234
+ return null;
235
+ }
236
+ }
237
+ #n() {
238
+ this.#t = this.getAttribute("name") ?? this.#t, this.#r = this.getAttribute("value") ?? this.#r;
239
+ }
240
+ #d = (e) => {
241
+ if (this.disabled) {
242
+ e.preventDefault(), e.stopImmediatePropagation();
243
+ return;
244
+ }
245
+ e.composedPath()[0] === this && (e.stopImmediatePropagation(), this.#a());
246
+ };
247
+ #h = (e) => {
248
+ this.disabled || e.key !== " " && e.key !== "Enter" || e.isTrusted || (e.preventDefault(), this.#a());
249
+ };
250
+ #l = (e) => {
251
+ e.stopPropagation(), this.indeterminate && (this.#e.indeterminate = !1, this.#e.checked = !0), this.indeterminate = this.#e.indeterminate, this.checked = this.#e.checked, this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 }));
252
+ };
253
+ #a() {
254
+ this.checked = this.indeterminate ? !0 : !this.checked, this.indeterminate = !1, this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 }));
255
+ }
256
+ #c() {
257
+ this.tabIndex = this.disabled ? -1 : this.tabIndex < 0 ? 0 : this.tabIndex, this.#e.checked = this.checked, this.#e.indeterminate = this.indeterminate, this.#e.disabled = this.disabled, this.#e.required = this.required, this.#e.name = this.#t, this.#e.value = this.#r, this.#b(), this.#y();
258
+ }
259
+ #b() {
260
+ this.#o.replaceChildren(this.#u());
261
+ }
262
+ #u() {
263
+ const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
264
+ if (e.setAttribute("data-ty-checkbox-mark", ""), e.setAttribute("viewBox", "0 0 12 12"), e.setAttribute("aria-hidden", "true"), e.setAttribute("fill", "currentColor"), this.indeterminate) {
265
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "rect");
266
+ t.setAttribute("x", "2"), t.setAttribute("y", "2"), t.setAttribute("width", "8"), t.setAttribute("height", "8"), t.setAttribute("rx", "1"), e.append(t);
267
+ } else {
268
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
269
+ t.setAttribute(
270
+ "d",
271
+ "M9.76 3.2c.3.29.32.76.04 1.06l-4.25 4.5a.75.75 0 0 1-1.08.02L2.22 6.53a.75.75 0 0 1 1.06-1.06l1.7 1.7L8.7 3.24a.75.75 0 0 1 1.06-.04Z"
272
+ ), e.append(t);
273
+ }
274
+ return e;
275
+ }
276
+ #y() {
277
+ if (this.#i?.setFormValue(
278
+ !this.disabled && this.checked && !this.indeterminate ? this.#r : null
279
+ ), this.required && !this.disabled && !this.checked) {
280
+ this.#i?.setValidity({ valueMissing: !0 }, "This field is required.", this.#e);
281
+ return;
282
+ }
283
+ this.#i?.setValidity({});
284
+ }
285
+ }
286
+ export {
287
+ s as TyuiCheckboxElement
288
+ };
@@ -0,0 +1,16 @@
1
+ export type TyuiClusterAlign = 'start' | 'center' | 'end' | 'baseline' | 'stretch';
2
+ export type TyuiClusterJustify = 'start' | 'center' | 'end' | 'between';
3
+ export declare class TyuiClusterElement extends HTMLElement {
4
+ #private;
5
+ static observedAttributes: string[];
6
+ connectedCallback(): void;
7
+ attributeChangedCallback(): void;
8
+ get align(): TyuiClusterAlign;
9
+ set align(value: TyuiClusterAlign);
10
+ get justify(): TyuiClusterJustify;
11
+ set justify(value: TyuiClusterJustify);
12
+ get gap(): string;
13
+ set gap(value: string);
14
+ get rowGap(): string | null;
15
+ set rowGap(value: string | null);
16
+ }
package/cluster.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './cluster/tyui-cluster';
package/cluster.js ADDED
@@ -0,0 +1,53 @@
1
+ import { i as r, n as i, s as e, b as a, a as s } from "./layout-helpers-C2WgKm6F.js";
2
+ const n = ["start", "center", "end", "baseline", "stretch"], l = ["start", "center", "end", "between"], u = {
3
+ baseline: "baseline",
4
+ center: "center",
5
+ end: "flex-end",
6
+ start: "flex-start",
7
+ stretch: "stretch"
8
+ }, g = {
9
+ between: "space-between",
10
+ center: "center",
11
+ end: "flex-end",
12
+ start: "flex-start"
13
+ };
14
+ class o extends HTMLElement {
15
+ static observedAttributes = ["align", "gap", "justify", "row-gap"];
16
+ connectedCallback() {
17
+ r(), this.#t();
18
+ }
19
+ attributeChangedCallback() {
20
+ this.#t();
21
+ }
22
+ get align() {
23
+ return i(this.getAttribute("align"), n, "center");
24
+ }
25
+ set align(t) {
26
+ e(this, "align", t);
27
+ }
28
+ get justify() {
29
+ return i(this.getAttribute("justify"), l, "start");
30
+ }
31
+ set justify(t) {
32
+ e(this, "justify", t);
33
+ }
34
+ get gap() {
35
+ return this.getAttribute("gap") ?? "2";
36
+ }
37
+ set gap(t) {
38
+ e(this, "gap", t);
39
+ }
40
+ get rowGap() {
41
+ return this.getAttribute("row-gap");
42
+ }
43
+ set rowGap(t) {
44
+ t === null ? this.removeAttribute("row-gap") : e(this, "row-gap", t);
45
+ }
46
+ #t() {
47
+ const t = a(this.getAttribute("gap"), "2");
48
+ s(this, "--ty-cluster-align", u[this.align]), s(this, "--ty-cluster-justify", g[this.justify]), s(this, "--ty-cluster-gap", t), s(this, "--ty-cluster-row-gap", this.rowGap ? a(this.rowGap, "2") : t);
49
+ }
50
+ }
51
+ export {
52
+ o as TyuiClusterElement
53
+ };
@@ -0,0 +1,14 @@
1
+ export type TyuiContainerSize = 'narrow' | 'medium' | 'wide' | 'full';
2
+ export type TyuiContainerGutter = '0' | '1' | '2' | '3' | '4' | 'page';
3
+ export declare class TyuiContainerElement extends HTMLElement {
4
+ #private;
5
+ static observedAttributes: string[];
6
+ connectedCallback(): void;
7
+ attributeChangedCallback(): void;
8
+ get size(): TyuiContainerSize;
9
+ set size(value: TyuiContainerSize);
10
+ get gutter(): TyuiContainerGutter;
11
+ set gutter(value: TyuiContainerGutter);
12
+ get bleed(): boolean;
13
+ set bleed(value: boolean);
14
+ }
package/container.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './container/tyui-container';
package/container.js ADDED
@@ -0,0 +1,44 @@
1
+ import { i as n, n as i, s as t, a as s, b as u } from "./layout-helpers-C2WgKm6F.js";
2
+ const l = ["narrow", "medium", "wide", "full"], a = ["0", "1", "2", "3", "4", "page"], o = {
3
+ full: "none",
4
+ medium: "var(--ty-container-medium, 60rem)",
5
+ narrow: "var(--ty-container-narrow, 42rem)",
6
+ wide: "var(--ty-container-wide, 72rem)"
7
+ };
8
+ function c(r) {
9
+ const e = i(r, a, "page");
10
+ return e === "page" ? "var(--ty-page-gutter, 1rem)" : u(e, "3");
11
+ }
12
+ class d extends HTMLElement {
13
+ static observedAttributes = ["bleed", "gutter", "size"];
14
+ connectedCallback() {
15
+ n(), this.#e();
16
+ }
17
+ attributeChangedCallback() {
18
+ this.#e();
19
+ }
20
+ get size() {
21
+ return i(this.getAttribute("size"), l, "wide");
22
+ }
23
+ set size(e) {
24
+ t(this, "size", e);
25
+ }
26
+ get gutter() {
27
+ return i(this.getAttribute("gutter"), a, "page");
28
+ }
29
+ set gutter(e) {
30
+ t(this, "gutter", e);
31
+ }
32
+ get bleed() {
33
+ return this.hasAttribute("bleed");
34
+ }
35
+ set bleed(e) {
36
+ t(this, "bleed", e);
37
+ }
38
+ #e() {
39
+ s(this, "--ty-container-max-inline-size", o[this.size]), s(this, "--ty-container-gutter", this.bleed ? "0" : c(this.gutter));
40
+ }
41
+ }
42
+ export {
43
+ d as TyuiContainerElement
44
+ };