@typeach/core 0.0.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/dist/favicon.ico +0 -0
- package/dist/typeach.js +306 -0
- package/dist/typeach.umd.cjs +12 -0
- package/package.json +55 -0
package/dist/favicon.ico
ADDED
|
Binary file
|
package/dist/typeach.js
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createVNode as a, defineComponent as o, inject as s, markRaw as c, mergeProps as ee, onBeforeUnmount as l, onMounted as u, openBlock as d, provide as f, ref as p, renderSlot as m, resolveDynamicComponent as h, unref as g, useId as _, useModel as v, useTemplateRef as y, watch as b, watchEffect as te, withCtx as x } from "vue";
|
|
2
|
+
import { defineStore as S } from "pinia";
|
|
3
|
+
//#region src/components/button/Button.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var C = [
|
|
5
|
+
"aria-disabled",
|
|
6
|
+
"disabled",
|
|
7
|
+
"type"
|
|
8
|
+
], w = /* @__PURE__ */ o({
|
|
9
|
+
__name: "Button",
|
|
10
|
+
props: {
|
|
11
|
+
type: { default: "button" },
|
|
12
|
+
disabled: {
|
|
13
|
+
type: [Boolean, String],
|
|
14
|
+
default: void 0
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
emits: ["click"],
|
|
18
|
+
setup(e, { emit: t }) {
|
|
19
|
+
let n = e, r = t, a = (e) => {
|
|
20
|
+
n.disabled || r("click", e);
|
|
21
|
+
};
|
|
22
|
+
return (t, n) => (d(), i("button", {
|
|
23
|
+
ref: "element",
|
|
24
|
+
"aria-disabled": e.disabled === !0 ? !0 : void 0,
|
|
25
|
+
disabled: e.disabled === "without-focus" ? !0 : void 0,
|
|
26
|
+
type: e.type,
|
|
27
|
+
onClick: a
|
|
28
|
+
}, [m(t.$slots, "default")], 8, C));
|
|
29
|
+
}
|
|
30
|
+
}), T = "\n height: 1px;\n width: 1px;\n\n position: absolute;\n overflow: hidden;\n\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n\n white-space: nowrap;\n", E = /* @__PURE__ */ o({
|
|
31
|
+
__name: "VisuallyHidden",
|
|
32
|
+
setup(e) {
|
|
33
|
+
return (e, t) => (d(), i("div", { style: T }, [m(e.$slots, "default")]));
|
|
34
|
+
}
|
|
35
|
+
}), D = /* @__PURE__ */ o({
|
|
36
|
+
__name: "CopyButton",
|
|
37
|
+
props: {
|
|
38
|
+
content: {},
|
|
39
|
+
onCopy: { type: Function }
|
|
40
|
+
},
|
|
41
|
+
emits: ["copy"],
|
|
42
|
+
setup(n) {
|
|
43
|
+
let o = p(!1), s = n, c = t(() => s.content ? typeof s.content == "string" ? [new ClipboardItem({ "text/plain": s.content })] : Array.isArray(s.content) ? s.content : [s.content] : []), l = async (e) => {
|
|
44
|
+
s.content ? await navigator.clipboard.write(c.value) : await s.onCopy?.(e), o.value = !0, setTimeout(() => {
|
|
45
|
+
o.value = !1;
|
|
46
|
+
}, 4e3);
|
|
47
|
+
};
|
|
48
|
+
return (t, n) => (d(), i(e, null, [a(g(E), { "aria-live": "polite" }, {
|
|
49
|
+
default: x(() => [o.value ? m(t.$slots, "default", {
|
|
50
|
+
key: 0,
|
|
51
|
+
isCopying: o.value
|
|
52
|
+
}) : r("", !0)]),
|
|
53
|
+
_: 3
|
|
54
|
+
}), a(g(w), ee(t.$attrs, { onClick: l }), {
|
|
55
|
+
default: x(() => [m(t.$slots, "default", { isCopying: o.value })]),
|
|
56
|
+
_: 3
|
|
57
|
+
}, 16)], 64));
|
|
58
|
+
}
|
|
59
|
+
}), O = /([\p{Ll}\d])(\p{Lu})/gu, ne = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu, re = /(\d)\p{Ll}|(\p{L})\d/u, ie = /[^\p{L}\d]+/giu, k = "$1\0$2", A = "";
|
|
60
|
+
function j(e) {
|
|
61
|
+
let t = e.trim();
|
|
62
|
+
t = t.replace(O, k).replace(ne, k), t = t.replace(ie, "\0");
|
|
63
|
+
let n = 0, r = t.length;
|
|
64
|
+
for (; t.charAt(n) === "\0";) n++;
|
|
65
|
+
if (n === r) return [];
|
|
66
|
+
for (; t.charAt(r - 1) === "\0";) r--;
|
|
67
|
+
return t.slice(n, r).split(/\0/g);
|
|
68
|
+
}
|
|
69
|
+
function M(e) {
|
|
70
|
+
let t = j(e);
|
|
71
|
+
for (let e = 0; e < t.length; e++) {
|
|
72
|
+
let n = t[e], r = re.exec(n);
|
|
73
|
+
if (r) {
|
|
74
|
+
let i = r.index + (r[1] ?? r[2]).length;
|
|
75
|
+
t.splice(e, 1, n.slice(0, i), n.slice(i));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return t;
|
|
79
|
+
}
|
|
80
|
+
function N(e, t) {
|
|
81
|
+
let [n, r, i] = I(e, t);
|
|
82
|
+
return n + r.map(F(t?.locale)).join(t?.delimiter ?? " ") + i;
|
|
83
|
+
}
|
|
84
|
+
function P(e, t) {
|
|
85
|
+
return N(e, {
|
|
86
|
+
delimiter: "-",
|
|
87
|
+
...t
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function F(e) {
|
|
91
|
+
return e === !1 ? (e) => e.toLowerCase() : (t) => t.toLocaleLowerCase(e);
|
|
92
|
+
}
|
|
93
|
+
function I(e, t = {}) {
|
|
94
|
+
let n = t.split ?? (t.separateNumbers ? M : j), r = t.prefixCharacters ?? A, i = t.suffixCharacters ?? A, a = 0, o = e.length;
|
|
95
|
+
for (; a < e.length;) {
|
|
96
|
+
let t = e.charAt(a);
|
|
97
|
+
if (!r.includes(t)) break;
|
|
98
|
+
a++;
|
|
99
|
+
}
|
|
100
|
+
for (; o > a;) {
|
|
101
|
+
let t = o - 1, n = e.charAt(t);
|
|
102
|
+
if (!i.includes(n)) break;
|
|
103
|
+
o = t;
|
|
104
|
+
}
|
|
105
|
+
return [
|
|
106
|
+
e.slice(0, a),
|
|
107
|
+
n(e.slice(a, o)),
|
|
108
|
+
e.slice(o)
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/hooks/useBemClass.ts
|
|
113
|
+
var L = (e, t) => {
|
|
114
|
+
let n = t ? `${t}-${e}` : e;
|
|
115
|
+
return (...e) => {
|
|
116
|
+
let t = [n, ...e].filter((e) => typeof e == "string").map((e) => P(e)).join("__"), r = { [t]: !0 };
|
|
117
|
+
for (let n of e.filter((e) => typeof e == "object")) for (let e of Object.keys(n)) {
|
|
118
|
+
let i = n[e];
|
|
119
|
+
typeof i == "string" && (r[`${t}--${i}`] = !0), typeof i == "number" && (r[`${t}--${P(e)}-${i}`] = !0), typeof i == "boolean" && (r[`${t}--${P(e)}`] = i);
|
|
120
|
+
}
|
|
121
|
+
return r;
|
|
122
|
+
};
|
|
123
|
+
}, R = (e) => (t) => L(t, e), z = (e, t) => (f(e, t), t), B = (e) => s(e, { missingContext: !0 }), V = (e) => s(e), H = (e) => e == null, U = (e) => {
|
|
124
|
+
let { disabled: t } = e.dataset;
|
|
125
|
+
return e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true" || !H(t) && t !== "";
|
|
126
|
+
}, W = (e, n) => {
|
|
127
|
+
let r = p(/* @__PURE__ */ new Map()), i = n ? {
|
|
128
|
+
items: r,
|
|
129
|
+
parent: n
|
|
130
|
+
} : s(`${e}-elements`, {
|
|
131
|
+
items: r,
|
|
132
|
+
parent: p()
|
|
133
|
+
});
|
|
134
|
+
return n && f(`${e}-elements`, i), {
|
|
135
|
+
getElements: (t = !0) => {
|
|
136
|
+
let n = i.parent.value;
|
|
137
|
+
if (!n) return [];
|
|
138
|
+
let r = Array.from(n?.querySelectorAll(`[data-elements-${e}="true"]`));
|
|
139
|
+
return Array.from(i.items.value.values()).sort((e, t) => r.indexOf(e) - r.indexOf(t)).filter((e) => t || !U(e));
|
|
140
|
+
},
|
|
141
|
+
elements: t(() => Array.from(i.items.value.values()))
|
|
142
|
+
};
|
|
143
|
+
}, G = (e, t, n) => {
|
|
144
|
+
let r = s(`${e}-elements`, void 0);
|
|
145
|
+
te((e) => {
|
|
146
|
+
if (!t.value) return;
|
|
147
|
+
let i = c(t.value);
|
|
148
|
+
n?.value ? r?.items.value.delete(i) : r?.items.value.set(i, t.value), e(() => r?.items.value.delete(i));
|
|
149
|
+
}), u(() => {
|
|
150
|
+
t.value?.setAttribute(`data-elements-${e}`, "true");
|
|
151
|
+
}), l(() => {
|
|
152
|
+
t.value?.removeAttribute(`data-elements-${e}`);
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
156
|
+
function K(e, t, n) {
|
|
157
|
+
return b(e, t, {
|
|
158
|
+
...n,
|
|
159
|
+
immediate: !0
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/hooks/useThemeSettingsStore.ts
|
|
164
|
+
var q = S("theme-settings", () => {
|
|
165
|
+
let e = p(1), t = p(!0), n = (e, t) => {
|
|
166
|
+
document.documentElement.style.setProperty(`--${e}`, t);
|
|
167
|
+
};
|
|
168
|
+
return K(e, (e) => {
|
|
169
|
+
document.documentElement.style.setProperty("saturation", `${e}`);
|
|
170
|
+
}), K(t, (e) => {
|
|
171
|
+
n("code-white-space", e ? "pre-wrap" : "pre");
|
|
172
|
+
}), {
|
|
173
|
+
saturation: e,
|
|
174
|
+
wrapCode: t
|
|
175
|
+
};
|
|
176
|
+
}), J = ["id"], Y = /* @__PURE__ */ o({
|
|
177
|
+
__name: "FieldDescription",
|
|
178
|
+
setup(e) {
|
|
179
|
+
let t = _(), n = y("element");
|
|
180
|
+
return G("field-description", n), (e, r) => (d(), i("div", {
|
|
181
|
+
id: g(t),
|
|
182
|
+
ref_key: "element",
|
|
183
|
+
ref: n
|
|
184
|
+
}, [m(e.$slots, "default")], 8, J));
|
|
185
|
+
}
|
|
186
|
+
}), ae = ["id"], oe = /* @__PURE__ */ o({
|
|
187
|
+
__name: "FieldError",
|
|
188
|
+
setup(e) {
|
|
189
|
+
let t = _(), n = y("element");
|
|
190
|
+
return G("field-error", n), (e, r) => (d(), i("div", {
|
|
191
|
+
id: g(t),
|
|
192
|
+
ref_key: "element",
|
|
193
|
+
ref: n
|
|
194
|
+
}, [m(e.$slots, "default")], 8, ae));
|
|
195
|
+
}
|
|
196
|
+
}), X = Symbol("field"), se = (e, n) => {
|
|
197
|
+
let { elements: r } = W("field-error", n), { elements: i } = W("field-description", n), a = (e) => e.filter((e) => e.id).map((e) => e.id);
|
|
198
|
+
return b(r, (e) => {
|
|
199
|
+
console.log(e);
|
|
200
|
+
}, { immediate: !0 }), z(X, {
|
|
201
|
+
id: e,
|
|
202
|
+
hasErrors: t(() => r.value.length > 0),
|
|
203
|
+
errorIds: t(() => a(r.value)),
|
|
204
|
+
descriptionIds: t(() => a(i.value))
|
|
205
|
+
});
|
|
206
|
+
}, Z = () => V(X), ce = ["id", "for"], le = /* @__PURE__ */ o({
|
|
207
|
+
__name: "FieldLabel",
|
|
208
|
+
setup(e) {
|
|
209
|
+
let { id: t } = Z(), n = () => {
|
|
210
|
+
document.getElementById(t)?.focus();
|
|
211
|
+
};
|
|
212
|
+
return (e, r) => (d(), i("label", {
|
|
213
|
+
id: `${g(t)}-label`,
|
|
214
|
+
for: g(t),
|
|
215
|
+
onClick: n
|
|
216
|
+
}, [m(e.$slots, "default")], 8, ce));
|
|
217
|
+
}
|
|
218
|
+
}), Q = Symbol("Switch-field"), ue = () => V(Q), de = /* @__PURE__ */ o({
|
|
219
|
+
__name: "SwitchField",
|
|
220
|
+
props: {
|
|
221
|
+
modelValue: {
|
|
222
|
+
type: Boolean,
|
|
223
|
+
default: !1
|
|
224
|
+
},
|
|
225
|
+
modelModifiers: {}
|
|
226
|
+
},
|
|
227
|
+
emits: ["update:modelValue"],
|
|
228
|
+
setup(e) {
|
|
229
|
+
let t = v(e, "modelValue"), n = _(), r = y("element");
|
|
230
|
+
return se(n, r), f(Q, {
|
|
231
|
+
id: n,
|
|
232
|
+
modelValue: t
|
|
233
|
+
}), (e, t) => (d(), i("div", {
|
|
234
|
+
ref_key: "element",
|
|
235
|
+
ref: r
|
|
236
|
+
}, [m(e.$slots, "default")], 512));
|
|
237
|
+
}
|
|
238
|
+
}), fe = { "aria-hidden": "true" }, pe = /* @__PURE__ */ o({
|
|
239
|
+
__name: "SwitchFieldStateLabel",
|
|
240
|
+
setup(e) {
|
|
241
|
+
return (e, t) => (d(), i("div", fe, [m(e.$slots, "default")]));
|
|
242
|
+
}
|
|
243
|
+
}), $ = [
|
|
244
|
+
"id",
|
|
245
|
+
"aria-checked",
|
|
246
|
+
"aria-describedby",
|
|
247
|
+
"aria-invalid",
|
|
248
|
+
"aria-labelledby",
|
|
249
|
+
"aria-disabled"
|
|
250
|
+
], me = /* @__PURE__ */ o({
|
|
251
|
+
__name: "SwitchFieldSwitchButton",
|
|
252
|
+
props: { disabled: { type: Boolean } },
|
|
253
|
+
setup(e) {
|
|
254
|
+
let t = e, { modelValue: n } = ue(), { id: r, hasErrors: a, errorIds: o, descriptionIds: s } = Z(), c = () => {
|
|
255
|
+
t.disabled || (n.value = !n.value);
|
|
256
|
+
};
|
|
257
|
+
return (t, ee) => (d(), i("button", {
|
|
258
|
+
id: g(r),
|
|
259
|
+
"aria-checked": g(n),
|
|
260
|
+
"aria-describedby": [g(o), g(s)].flat().join(" ") || void 0,
|
|
261
|
+
"aria-invalid": g(a) ? !0 : void 0,
|
|
262
|
+
"aria-labelledby": `${g(r)}-label`,
|
|
263
|
+
"aria-disabled": e.disabled,
|
|
264
|
+
role: "switch",
|
|
265
|
+
type: "button",
|
|
266
|
+
onClick: c
|
|
267
|
+
}, [m(t.$slots, "default")], 8, $));
|
|
268
|
+
}
|
|
269
|
+
}), he = /* @__PURE__ */ o({
|
|
270
|
+
__name: "Table",
|
|
271
|
+
setup(e) {
|
|
272
|
+
return (e, t) => (d(), i("table", null, [m(e.$slots, "default")]));
|
|
273
|
+
}
|
|
274
|
+
}), ge = /* @__PURE__ */ o({
|
|
275
|
+
__name: "TableBody",
|
|
276
|
+
setup(e) {
|
|
277
|
+
return (e, t) => (d(), i("tbody", null, [m(e.$slots, "default")]));
|
|
278
|
+
}
|
|
279
|
+
}), _e = /* @__PURE__ */ o({
|
|
280
|
+
__name: "TableCell",
|
|
281
|
+
props: { heading: { type: Boolean } },
|
|
282
|
+
setup(e) {
|
|
283
|
+
return (t, r) => (d(), n(h(e.heading ? "th" : "td"), { scope: e.heading ? "row" : void 0 }, {
|
|
284
|
+
default: x(() => [m(t.$slots, "default")]),
|
|
285
|
+
_: 3
|
|
286
|
+
}, 8, ["scope"]));
|
|
287
|
+
}
|
|
288
|
+
}), ve = /* @__PURE__ */ o({
|
|
289
|
+
__name: "TableHead",
|
|
290
|
+
setup(e) {
|
|
291
|
+
return (e, t) => (d(), i("thead", null, [m(e.$slots, "default")]));
|
|
292
|
+
}
|
|
293
|
+
}), ye = ["aria-sort"], be = /* @__PURE__ */ o({
|
|
294
|
+
__name: "TableHeadingCell",
|
|
295
|
+
props: { sorted: {} },
|
|
296
|
+
setup(e) {
|
|
297
|
+
return (t, n) => (d(), i("th", { "aria-sort": e.sorted }, [m(t.$slots, "default")], 8, ye));
|
|
298
|
+
}
|
|
299
|
+
}), xe = /* @__PURE__ */ o({
|
|
300
|
+
__name: "TableRow",
|
|
301
|
+
setup(e) {
|
|
302
|
+
return (e, t) => (d(), i("tr", null, [m(e.$slots, "default")]));
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
//#endregion
|
|
306
|
+
export { w as PeachyButton, D as PeachyCopyButton, Y as PeachyFieldDescription, oe as PeachyFieldError, le as PeachyFieldLabel, me as PeachySwitchButton, de as PeachySwitchField, pe as PeachySwitchStateLabel, he as PeachyTable, ge as PeachyTableBody, _e as PeachyTableCell, ve as PeachyTableHead, be as PeachyTableHeadingCell, xe as PeachyTableRow, E as PeachyVisuallyHidden, G as provideElement, L as useBemClass, V as useContext, z as useContextProvider, W as useElements, R as useGlobalBemClass, B as useOptionalContext, q as useThemeSettingsStore };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue"),require("pinia")):typeof define==`function`&&define.amd?define([`exports`,`vue`,`pinia`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Typeach={},e.Vue,e.pinia))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=[`aria-disabled`,`disabled`,`type`],i=(0,t.defineComponent)({__name:`Button`,props:{type:{default:`button`},disabled:{type:[Boolean,String],default:void 0}},emits:[`click`],setup(e,{emit:n}){let i=e,a=n,o=e=>{i.disabled||a(`click`,e)};return(n,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{ref:`element`,"aria-disabled":e.disabled===!0?!0:void 0,disabled:e.disabled===`without-focus`?!0:void 0,type:e.type,onClick:o},[(0,t.renderSlot)(n.$slots,`default`)],8,r))}}),a=`
|
|
2
|
+
height: 1px;
|
|
3
|
+
width: 1px;
|
|
4
|
+
|
|
5
|
+
position: absolute;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
|
|
8
|
+
clip: rect(0 0 0 0);
|
|
9
|
+
clip-path: inset(50%);
|
|
10
|
+
|
|
11
|
+
white-space: nowrap;
|
|
12
|
+
`,o=(0,t.defineComponent)({__name:`VisuallyHidden`,setup(e){return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{style:a},[(0,t.renderSlot)(e.$slots,`default`)]))}}),s=(0,t.defineComponent)({__name:`CopyButton`,props:{content:{},onCopy:{type:Function}},emits:[`copy`],setup(e){let n=(0,t.ref)(!1),r=e,a=(0,t.computed)(()=>r.content?typeof r.content==`string`?[new ClipboardItem({"text/plain":r.content})]:Array.isArray(r.content)?r.content:[r.content]:[]),s=async e=>{r.content?await navigator.clipboard.write(a.value):await r.onCopy?.(e),n.value=!0,setTimeout(()=>{n.value=!1},4e3)};return(e,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,null,[(0,t.createVNode)((0,t.unref)(o),{"aria-live":`polite`},{default:(0,t.withCtx)(()=>[n.value?(0,t.renderSlot)(e.$slots,`default`,{key:0,isCopying:n.value}):(0,t.createCommentVNode)(``,!0)]),_:3}),(0,t.createVNode)((0,t.unref)(i),(0,t.mergeProps)(e.$attrs,{onClick:s}),{default:(0,t.withCtx)(()=>[(0,t.renderSlot)(e.$slots,`default`,{isCopying:n.value})]),_:3},16)],64))}}),c=/([\p{Ll}\d])(\p{Lu})/gu,l=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,u=/(\d)\p{Ll}|(\p{L})\d/u,d=/[^\p{L}\d]+/giu,f=`$1\0$2`,p=``;function m(e){let t=e.trim();t=t.replace(c,f).replace(l,f),t=t.replace(d,`\0`);let n=0,r=t.length;for(;t.charAt(n)===`\0`;)n++;if(n===r)return[];for(;t.charAt(r-1)===`\0`;)r--;return t.slice(n,r).split(/\0/g)}function h(e){let t=m(e);for(let e=0;e<t.length;e++){let n=t[e],r=u.exec(n);if(r){let i=r.index+(r[1]??r[2]).length;t.splice(e,1,n.slice(0,i),n.slice(i))}}return t}function g(e,t){let[n,r,i]=y(e,t);return n+r.map(v(t?.locale)).join(t?.delimiter??` `)+i}function _(e,t){return g(e,{delimiter:`-`,...t})}function v(e){return e===!1?e=>e.toLowerCase():t=>t.toLocaleLowerCase(e)}function y(e,t={}){let n=t.split??(t.separateNumbers?h:m),r=t.prefixCharacters??p,i=t.suffixCharacters??p,a=0,o=e.length;for(;a<e.length;){let t=e.charAt(a);if(!r.includes(t))break;a++}for(;o>a;){let t=o-1,n=e.charAt(t);if(!i.includes(n))break;o=t}return[e.slice(0,a),n(e.slice(a,o)),e.slice(o)]}var b=(e,t)=>{let n=t?`${t}-${e}`:e;return(...e)=>{let t=[n,...e].filter(e=>typeof e==`string`).map(e=>_(e)).join(`__`),r={[t]:!0};for(let n of e.filter(e=>typeof e==`object`))for(let e of Object.keys(n)){let i=n[e];typeof i==`string`&&(r[`${t}--${i}`]=!0),typeof i==`number`&&(r[`${t}--${_(e)}-${i}`]=!0),typeof i==`boolean`&&(r[`${t}--${_(e)}`]=i)}return r}},x=e=>t=>b(t,e),S=(e,n)=>((0,t.provide)(e,n),n),C=e=>(0,t.inject)(e,{missingContext:!0}),w=e=>(0,t.inject)(e),T=e=>e==null,E=e=>{let{disabled:t}=e.dataset;return e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`||!T(t)&&t!==``},D=(e,n)=>{let r=(0,t.ref)(new Map),i=n?{items:r,parent:n}:(0,t.inject)(`${e}-elements`,{items:r,parent:(0,t.ref)()});return n&&(0,t.provide)(`${e}-elements`,i),{getElements:(t=!0)=>{let n=i.parent.value;if(!n)return[];let r=Array.from(n?.querySelectorAll(`[data-elements-${e}="true"]`));return Array.from(i.items.value.values()).sort((e,t)=>r.indexOf(e)-r.indexOf(t)).filter(e=>t||!E(e))},elements:(0,t.computed)(()=>Array.from(i.items.value.values()))}},O=(e,n,r)=>{let i=(0,t.inject)(`${e}-elements`,void 0);(0,t.watchEffect)(e=>{if(!n.value)return;let a=(0,t.markRaw)(n.value);r?.value?i?.items.value.delete(a):i?.items.value.set(a,n.value),e(()=>i?.items.value.delete(a))}),(0,t.onMounted)(()=>{n.value?.setAttribute(`data-elements-${e}`,`true`)}),(0,t.onBeforeUnmount)(()=>{n.value?.removeAttribute(`data-elements-${e}`)})};typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;function k(e,n,r){return(0,t.watch)(e,n,{...r,immediate:!0})}var A=(0,n.defineStore)(`theme-settings`,()=>{let e=(0,t.ref)(1),n=(0,t.ref)(!0),r=(e,t)=>{document.documentElement.style.setProperty(`--${e}`,t)};return k(e,e=>{document.documentElement.style.setProperty(`saturation`,`${e}`)}),k(n,e=>{r(`code-white-space`,e?`pre-wrap`:`pre`)}),{saturation:e,wrapCode:n}}),j=[`id`],M=(0,t.defineComponent)({__name:`FieldDescription`,setup(e){let n=(0,t.useId)(),r=(0,t.useTemplateRef)(`element`);return O(`field-description`,r),(e,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{id:(0,t.unref)(n),ref_key:`element`,ref:r},[(0,t.renderSlot)(e.$slots,`default`)],8,j))}}),N=[`id`],P=(0,t.defineComponent)({__name:`FieldError`,setup(e){let n=(0,t.useId)(),r=(0,t.useTemplateRef)(`element`);return O(`field-error`,r),(e,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{id:(0,t.unref)(n),ref_key:`element`,ref:r},[(0,t.renderSlot)(e.$slots,`default`)],8,N))}}),F=Symbol(`field`),I=(e,n)=>{let{elements:r}=D(`field-error`,n),{elements:i}=D(`field-description`,n),a=e=>e.filter(e=>e.id).map(e=>e.id);return(0,t.watch)(r,e=>{console.log(e)},{immediate:!0}),S(F,{id:e,hasErrors:(0,t.computed)(()=>r.value.length>0),errorIds:(0,t.computed)(()=>a(r.value)),descriptionIds:(0,t.computed)(()=>a(i.value))})},L=()=>w(F),R=[`id`,`for`],z=(0,t.defineComponent)({__name:`FieldLabel`,setup(e){let{id:n}=L(),r=()=>{document.getElementById(n)?.focus()};return(e,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`label`,{id:`${(0,t.unref)(n)}-label`,for:(0,t.unref)(n),onClick:r},[(0,t.renderSlot)(e.$slots,`default`)],8,R))}}),B=Symbol(`Switch-field`),V=()=>w(B),H=(0,t.defineComponent)({__name:`SwitchField`,props:{modelValue:{type:Boolean,default:!1},modelModifiers:{}},emits:[`update:modelValue`],setup(e){let n=(0,t.useModel)(e,`modelValue`),r=(0,t.useId)(),i=(0,t.useTemplateRef)(`element`);return I(r,i),(0,t.provide)(B,{id:r,modelValue:n}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`element`,ref:i},[(0,t.renderSlot)(e.$slots,`default`)],512))}}),U={"aria-hidden":`true`},W=(0,t.defineComponent)({__name:`SwitchFieldStateLabel`,setup(e){return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,U,[(0,t.renderSlot)(e.$slots,`default`)]))}}),G=[`id`,`aria-checked`,`aria-describedby`,`aria-invalid`,`aria-labelledby`,`aria-disabled`],K=(0,t.defineComponent)({__name:`SwitchFieldSwitchButton`,props:{disabled:{type:Boolean}},setup(e){let n=e,{modelValue:r}=V(),{id:i,hasErrors:a,errorIds:o,descriptionIds:s}=L(),c=()=>{n.disabled||(r.value=!r.value)};return(n,l)=>((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{id:(0,t.unref)(i),"aria-checked":(0,t.unref)(r),"aria-describedby":[(0,t.unref)(o),(0,t.unref)(s)].flat().join(` `)||void 0,"aria-invalid":(0,t.unref)(a)?!0:void 0,"aria-labelledby":`${(0,t.unref)(i)}-label`,"aria-disabled":e.disabled,role:`switch`,type:`button`,onClick:c},[(0,t.renderSlot)(n.$slots,`default`)],8,G))}}),q=(0,t.defineComponent)({__name:`Table`,setup(e){return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`table`,null,[(0,t.renderSlot)(e.$slots,`default`)]))}}),J=(0,t.defineComponent)({__name:`TableBody`,setup(e){return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`tbody`,null,[(0,t.renderSlot)(e.$slots,`default`)]))}}),Y=(0,t.defineComponent)({__name:`TableCell`,props:{heading:{type:Boolean}},setup(e){return(n,r)=>((0,t.openBlock)(),(0,t.createBlock)((0,t.resolveDynamicComponent)(e.heading?`th`:`td`),{scope:e.heading?`row`:void 0},{default:(0,t.withCtx)(()=>[(0,t.renderSlot)(n.$slots,`default`)]),_:3},8,[`scope`]))}}),X=(0,t.defineComponent)({__name:`TableHead`,setup(e){return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`thead`,null,[(0,t.renderSlot)(e.$slots,`default`)]))}}),Z=[`aria-sort`],Q=(0,t.defineComponent)({__name:`TableHeadingCell`,props:{sorted:{}},setup(e){return(n,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`th`,{"aria-sort":e.sorted},[(0,t.renderSlot)(n.$slots,`default`)],8,Z))}}),$=(0,t.defineComponent)({__name:`TableRow`,setup(e){return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`tr`,null,[(0,t.renderSlot)(e.$slots,`default`)]))}});e.PeachyButton=i,e.PeachyCopyButton=s,e.PeachyFieldDescription=M,e.PeachyFieldError=P,e.PeachyFieldLabel=z,e.PeachySwitchButton=K,e.PeachySwitchField=H,e.PeachySwitchStateLabel=W,e.PeachyTable=q,e.PeachyTableBody=J,e.PeachyTableCell=Y,e.PeachyTableHead=X,e.PeachyTableHeadingCell=Q,e.PeachyTableRow=$,e.PeachyVisuallyHidden=o,e.provideElement=O,e.useBemClass=b,e.useContext=w,e.useContextProvider=S,e.useElements=D,e.useGlobalBemClass=x,e.useOptionalContext=C,e.useThemeSettingsStore=A});
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@typeach/core",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Component library for Vue.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "github:sq11y/typeach"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/typeach.umd.cjs",
|
|
15
|
+
"module": "./dist/typeach.js",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/typeach.js",
|
|
19
|
+
"require": "./dist/typeach.umd.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@axe-core/playwright": "^4.11.3",
|
|
24
|
+
"@vueuse/core": "^14.3.0",
|
|
25
|
+
"change-case": "^5.4.4"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@playwright/experimental-ct-vue": "^1.60.0",
|
|
29
|
+
"@tsconfig/node24": "^24.0.4",
|
|
30
|
+
"@types/node": "^24.12.2",
|
|
31
|
+
"@vitejs/plugin-vue": "^6.0.6",
|
|
32
|
+
"@vue/compiler-dom": "^3.5.38",
|
|
33
|
+
"@vue/tsconfig": "^0.9.1",
|
|
34
|
+
"jiti": "^2.6.1",
|
|
35
|
+
"npm-run-all2": "^8.0.4",
|
|
36
|
+
"rimraf": "^6.1.3",
|
|
37
|
+
"start-server-and-test": "^2.1.5",
|
|
38
|
+
"typescript": "~6.0.0",
|
|
39
|
+
"vite": "^8.0.16",
|
|
40
|
+
"vite-plugin-vue-devtools": "^8.1.1",
|
|
41
|
+
"vite-plus": "latest",
|
|
42
|
+
"vue-tsc": "^3.2.6"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"pinia": "^3.0.4",
|
|
46
|
+
"vue": "^3.5.38",
|
|
47
|
+
"vue-router": "^5.1.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"dev": "playwright test -c playwright-ct.config.ts --ui && rimraf .tmp",
|
|
51
|
+
"build": "run-p type-check \"build-only {@}\" --",
|
|
52
|
+
"build-only": "vp build",
|
|
53
|
+
"type-check": "vue-tsc --build"
|
|
54
|
+
}
|
|
55
|
+
}
|