blessing-ui 0.1.0 → 0.2.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/CHANGELOG.md +38 -0
- package/README.md +65 -43
- package/dist/blessing-ui.css +60 -0
- package/dist/components/BlessCodeBlock.css +1 -0
- package/dist/components/BlessCodeBlock.js +6 -0
- package/dist/components/BlessCodeBlock.vue.d.ts +62 -0
- package/dist/components/BlessCodeBlock.vue_vue_type_script_setup_true_lang.js +134 -0
- package/dist/components/BlessCountUp.css +1 -0
- package/dist/components/BlessCountUp.js +6 -0
- package/dist/components/BlessCountUp.vue.d.ts +18 -0
- package/dist/components/BlessCountUp.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/components/BlessCropper.css +1 -0
- package/dist/components/BlessCropper.js +6 -0
- package/dist/components/BlessCropper.vue.d.ts +54 -0
- package/dist/components/BlessCropper.vue_vue_type_script_setup_true_lang.js +212 -0
- package/dist/components/BlessDiff.css +1 -0
- package/dist/components/BlessDiff.js +6 -0
- package/dist/components/BlessDiff.vue.d.ts +22 -0
- package/dist/components/BlessDiff.vue_vue_type_script_setup_true_lang.js +148 -0
- package/dist/components/BlessGantt.css +1 -0
- package/dist/components/BlessGantt.js +6 -0
- package/dist/components/BlessGantt.vue.d.ts +69 -0
- package/dist/components/BlessGantt.vue_vue_type_script_setup_true_lang.js +270 -0
- package/dist/components/BlessGauge.css +1 -0
- package/dist/components/BlessGauge.js +6 -0
- package/dist/components/BlessGauge.vue.d.ts +36 -0
- package/dist/components/BlessGauge.vue_vue_type_script_setup_true_lang.js +100 -0
- package/dist/components/BlessHeatmapCalendar.css +1 -0
- package/dist/components/BlessHeatmapCalendar.js +6 -0
- package/dist/components/BlessHeatmapCalendar.vue.d.ts +38 -0
- package/dist/components/BlessHeatmapCalendar.vue_vue_type_script_setup_true_lang.js +146 -0
- package/dist/components/BlessHotspots.css +1 -0
- package/dist/components/BlessHotspots.js +6 -0
- package/dist/components/BlessHotspots.vue.d.ts +49 -0
- package/dist/components/BlessHotspots.vue_vue_type_script_setup_true_lang.js +127 -0
- package/dist/components/BlessKanban.css +1 -0
- package/dist/components/BlessKanban.js +6 -0
- package/dist/components/BlessKanban.vue.d.ts +55 -0
- package/dist/components/BlessKanban.vue_vue_type_script_setup_true_lang.js +165 -0
- package/dist/components/BlessLoupe.css +1 -0
- package/dist/components/BlessLoupe.js +6 -0
- package/dist/components/BlessLoupe.vue.d.ts +16 -0
- package/dist/components/BlessLoupe.vue_vue_type_script_setup_true_lang.js +93 -0
- package/dist/components/BlessMarquee.css +1 -0
- package/dist/components/BlessMarquee.js +6 -0
- package/dist/components/BlessMarquee.vue.d.ts +40 -0
- package/dist/components/BlessMarquee.vue_vue_type_script_setup_true_lang.js +64 -0
- package/dist/components/BlessMasonry.css +1 -0
- package/dist/components/BlessMasonry.js +6 -0
- package/dist/components/BlessMasonry.vue.d.ts +33 -0
- package/dist/components/BlessMasonry.vue_vue_type_script_setup_true_lang.js +79 -0
- package/dist/components/BlessMention.css +1 -0
- package/dist/components/BlessMention.js +6 -0
- package/dist/components/BlessMention.vue.d.ts +32 -0
- package/dist/components/BlessMention.vue_vue_type_script_setup_true_lang.js +116 -0
- package/dist/components/BlessRadialMenu.css +1 -0
- package/dist/components/BlessRadialMenu.js +6 -0
- package/dist/components/BlessRadialMenu.vue.d.ts +45 -0
- package/dist/components/BlessRadialMenu.vue_vue_type_script_setup_true_lang.js +146 -0
- package/dist/components/BlessShortcutRecorder.css +1 -0
- package/dist/components/BlessShortcutRecorder.js +6 -0
- package/dist/components/BlessShortcutRecorder.vue.d.ts +29 -0
- package/dist/components/BlessShortcutRecorder.vue_vue_type_script_setup_true_lang.js +116 -0
- package/dist/components/BlessSliderCaptcha.css +1 -0
- package/dist/components/BlessSliderCaptcha.js +6 -0
- package/dist/components/BlessSliderCaptcha.vue.d.ts +33 -0
- package/dist/components/BlessSliderCaptcha.vue_vue_type_script_setup_true_lang.js +141 -0
- package/dist/components/BlessSortable.css +1 -0
- package/dist/components/BlessSortable.js +6 -0
- package/dist/components/BlessSortable.vue.d.ts +33 -0
- package/dist/components/BlessSortable.vue_vue_type_script_setup_true_lang.js +87 -0
- package/dist/components/BlessSplitView.css +1 -0
- package/dist/components/BlessSplitView.js +6 -0
- package/dist/components/BlessSplitView.vue.d.ts +61 -0
- package/dist/components/BlessSplitView.vue_vue_type_script_setup_true_lang.js +92 -0
- package/dist/components/BlessSwipeDeck.css +1 -0
- package/dist/components/BlessSwipeDeck.js +6 -0
- package/dist/components/BlessSwipeDeck.vue.d.ts +46 -0
- package/dist/components/BlessSwipeDeck.vue_vue_type_script_setup_true_lang.js +199 -0
- package/dist/components/BlessTimer.css +1 -0
- package/dist/components/BlessTimer.js +6 -0
- package/dist/components/BlessTimer.vue.d.ts +56 -0
- package/dist/components/BlessTimer.vue_vue_type_script_setup_true_lang.js +130 -0
- package/dist/composables/cropBox.d.ts +22 -0
- package/dist/composables/cropBox.js +39 -0
- package/dist/composables/diffLines.d.ts +10 -0
- package/dist/composables/diffLines.js +55 -0
- package/dist/composables/radial.d.ts +15 -0
- package/dist/composables/radial.js +22 -0
- package/dist/composables/shortcut.d.ts +12 -0
- package/dist/composables/shortcut.js +35 -0
- package/dist/composables/useSortable.d.ts +18 -0
- package/dist/composables/useSortable.js +34 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +78 -53
- package/package.json +20 -18
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, defineComponent as o, mergeModels as s, nextTick as c, normalizeClass as l, onBeforeUnmount as u, openBlock as d, ref as f, renderList as p, renderSlot as m, toDisplayString as h, unref as g, useId as _, useModel as v } from "vue";
|
|
2
|
+
//#region src/components/BlessCodeBlock.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
+
var y = { class: "bless-code" }, b = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "bless-code__head"
|
|
6
|
+
}, x = ["aria-label"], S = [
|
|
7
|
+
"id",
|
|
8
|
+
"aria-selected",
|
|
9
|
+
"aria-controls",
|
|
10
|
+
"tabindex",
|
|
11
|
+
"onClick"
|
|
12
|
+
], C = {
|
|
13
|
+
key: 1,
|
|
14
|
+
class: "bless-code__name"
|
|
15
|
+
}, w = {
|
|
16
|
+
key: 2,
|
|
17
|
+
class: "bless-code__lang"
|
|
18
|
+
}, T = [
|
|
19
|
+
"id",
|
|
20
|
+
"role",
|
|
21
|
+
"aria-labelledby",
|
|
22
|
+
"aria-label"
|
|
23
|
+
], E = {
|
|
24
|
+
key: 0,
|
|
25
|
+
class: "bless-code__no",
|
|
26
|
+
"aria-hidden": "true"
|
|
27
|
+
}, D = {
|
|
28
|
+
class: "bless-code__live",
|
|
29
|
+
"aria-live": "polite"
|
|
30
|
+
}, O = /*@__PURE__*/ o({
|
|
31
|
+
name: "BlessCodeBlock",
|
|
32
|
+
__name: "BlessCodeBlock",
|
|
33
|
+
props: /*@__PURE__*/ s({
|
|
34
|
+
code: {},
|
|
35
|
+
lang: {},
|
|
36
|
+
filename: {},
|
|
37
|
+
files: {},
|
|
38
|
+
lines: {},
|
|
39
|
+
lineNumbers: { type: Boolean },
|
|
40
|
+
copy: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: !0
|
|
43
|
+
},
|
|
44
|
+
wrap: { type: Boolean },
|
|
45
|
+
label: { default: "Code" }
|
|
46
|
+
}, {
|
|
47
|
+
active: { default: 0 },
|
|
48
|
+
activeModifiers: {}
|
|
49
|
+
}),
|
|
50
|
+
emits: /*@__PURE__*/ s(["copy"], ["update:active"]),
|
|
51
|
+
setup(o, { emit: s }) {
|
|
52
|
+
let O = o, k = v(o, "active"), A = s, j = _(), M = t(() => (O.files?.length ? O.files[Math.min(k.value, O.files.length - 1)] : void 0) ?? {
|
|
53
|
+
name: O.filename ?? "",
|
|
54
|
+
code: O.code ?? "",
|
|
55
|
+
lang: O.lang
|
|
56
|
+
}), N = t(() => M.value.lang ?? O.lang), P = t(() => {
|
|
57
|
+
let e = /* @__PURE__ */ new Set();
|
|
58
|
+
if (Array.isArray(O.lines)) O.lines.forEach((t) => e.add(t));
|
|
59
|
+
else for (let t of (O.lines ?? "").split(",")) {
|
|
60
|
+
let [n, r] = t.split("-").map((e) => parseInt(e, 10));
|
|
61
|
+
if (n) for (let t = n; t <= (r ?? n); t++) e.add(t);
|
|
62
|
+
}
|
|
63
|
+
return e;
|
|
64
|
+
}), F = t(() => M.value.code.replace(/\n$/, "").split("\n").map((e, t) => ({
|
|
65
|
+
n: t + 1,
|
|
66
|
+
text: e,
|
|
67
|
+
hl: P.value.has(t + 1)
|
|
68
|
+
}))), I = f();
|
|
69
|
+
function L(e) {
|
|
70
|
+
let t = O.files?.length ?? 0, n = e.key === "ArrowRight" ? k.value + 1 : e.key === "ArrowLeft" ? k.value - 1 : e.key === "Home" ? 0 : e.key === "End" ? t - 1 : null;
|
|
71
|
+
n != null && (e.preventDefault(), k.value = (n + t) % t, c(() => I.value?.querySelectorAll("[role=\"tab\"]")[k.value]?.focus()));
|
|
72
|
+
}
|
|
73
|
+
let R = f(!1), z;
|
|
74
|
+
async function B() {
|
|
75
|
+
let e = M.value.code;
|
|
76
|
+
try {
|
|
77
|
+
await navigator.clipboard.writeText(e);
|
|
78
|
+
} catch {
|
|
79
|
+
let t = document.createElement("textarea");
|
|
80
|
+
t.value = e, t.style.position = "fixed", t.style.opacity = "0", document.body.append(t), t.select(), document.execCommand("copy"), t.remove();
|
|
81
|
+
}
|
|
82
|
+
A("copy", e), R.value = !0, clearTimeout(z), z = setTimeout(() => R.value = !1, 2e3);
|
|
83
|
+
}
|
|
84
|
+
return u(() => clearTimeout(z)), (t, s) => (d(), r("figure", y, [
|
|
85
|
+
o.files?.length || o.filename || N.value || o.copy ? (d(), r("figcaption", b, [
|
|
86
|
+
o.files?.length ? (d(), r("div", {
|
|
87
|
+
key: 0,
|
|
88
|
+
ref_key: "tabs",
|
|
89
|
+
ref: I,
|
|
90
|
+
class: "bless-code__tabs",
|
|
91
|
+
role: "tablist",
|
|
92
|
+
"aria-label": o.label
|
|
93
|
+
}, [(d(!0), r(e, null, p(o.files, (e, t) => (d(), r("button", {
|
|
94
|
+
id: `${g(j)}-t${t}`,
|
|
95
|
+
key: e.name,
|
|
96
|
+
type: "button",
|
|
97
|
+
role: "tab",
|
|
98
|
+
class: "bless-code__tab",
|
|
99
|
+
"aria-selected": t === k.value,
|
|
100
|
+
"aria-controls": `${g(j)}-p`,
|
|
101
|
+
tabindex: t === k.value ? 0 : -1,
|
|
102
|
+
onClick: (e) => k.value = t,
|
|
103
|
+
onKeydown: L
|
|
104
|
+
}, h(e.name), 41, S))), 128))], 8, x)) : o.filename ? (d(), r("span", C, h(o.filename), 1)) : n("", !0),
|
|
105
|
+
s[0] ||= i("span", { class: "bless-code__spacer" }, null, -1),
|
|
106
|
+
N.value ? (d(), r("span", w, h(N.value), 1)) : n("", !0),
|
|
107
|
+
o.copy ? (d(), r("button", {
|
|
108
|
+
key: 3,
|
|
109
|
+
type: "button",
|
|
110
|
+
class: "bless-code__copy",
|
|
111
|
+
onClick: B
|
|
112
|
+
}, h(R.value ? "Copied" : "Copy"), 1)) : n("", !0)
|
|
113
|
+
])) : n("", !0),
|
|
114
|
+
i("div", {
|
|
115
|
+
id: `${g(j)}-p`,
|
|
116
|
+
class: "bless-code__scroll",
|
|
117
|
+
tabindex: "0",
|
|
118
|
+
role: o.files?.length ? "tabpanel" : "region",
|
|
119
|
+
"aria-labelledby": o.files?.length ? `${g(j)}-t${k.value}` : void 0,
|
|
120
|
+
"aria-label": o.files?.length ? void 0 : M.value.name || o.label
|
|
121
|
+
}, [m(t.$slots, "code", {
|
|
122
|
+
code: M.value.code,
|
|
123
|
+
lang: N.value,
|
|
124
|
+
lines: F.value
|
|
125
|
+
}, () => [i("pre", { class: l(["bless-code__pre", { "bless-code__pre--wrap": o.wrap }]) }, [i("code", null, [(d(!0), r(e, null, p(F.value, (e) => (d(), r("span", {
|
|
126
|
+
key: e.n,
|
|
127
|
+
class: l(["bless-code__line", { "bless-code__line--hl": e.hl }])
|
|
128
|
+
}, [o.lineNumbers ? (d(), r("span", E, h(e.n), 1)) : n("", !0), a(h(e.text) + "\n", 1)], 2))), 128))])], 2)])], 8, T),
|
|
129
|
+
i("span", D, h(R.value ? "Copied to clipboard" : ""), 1)
|
|
130
|
+
]));
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
//#endregion
|
|
134
|
+
export { O as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.bless-countup{font-variant-numeric:tabular-nums;position:relative}.bless-countup--odometer .bless-countup__visual{display:inline-flex}.bless-countup__digit{height:1lh;display:inline-block;overflow:hidden}.bless-countup__reel{translate:0 calc(var(--bless-digit) * -1lh);transition:translate var(--bless-duration-slow) var(--bless-ease-out);flex-direction:column;display:flex}.bless-countup__reel i{height:1lh;font-style:normal}.bless-countup__final{clip-path:inset(50%);width:1px;height:1px;position:absolute;overflow:hidden}@media (prefers-reduced-motion:reduce){.bless-countup__reel{transition:none}}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
value: number;
|
|
3
|
+
/** milliseconds to travel from the shown number to `value` */
|
|
4
|
+
duration?: number;
|
|
5
|
+
locale?: string;
|
|
6
|
+
/** `Intl.NumberFormat` options: `{ style: "currency", currency: "IDR" }` */
|
|
7
|
+
options?: Intl.NumberFormatOptions;
|
|
8
|
+
/** start at 0 and count up when first shown; off shows `value` straight away */
|
|
9
|
+
appear?: boolean;
|
|
10
|
+
/** roll each digit in its own column, like an odometer */
|
|
11
|
+
odometer?: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
14
|
+
duration: number;
|
|
15
|
+
appear: boolean;
|
|
16
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
17
|
+
declare const _default: typeof __VLS_export;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { reducedMotion as e } from "../composables/useMedia.js";
|
|
2
|
+
import { Fragment as t, computed as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, defineComponent as o, normalizeClass as s, normalizeStyle as c, onBeforeUnmount as l, onMounted as u, openBlock as d, ref as f, renderList as p, toDisplayString as m, watch as h } from "vue";
|
|
3
|
+
//#region src/components/BlessCountUp.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var g = {
|
|
5
|
+
class: "bless-countup__visual",
|
|
6
|
+
"aria-hidden": "true"
|
|
7
|
+
}, _ = {
|
|
8
|
+
key: 0,
|
|
9
|
+
class: "bless-countup__digit"
|
|
10
|
+
}, v = { key: 1 }, y = { class: "bless-countup__final" }, b = /*@__PURE__*/ o({
|
|
11
|
+
name: "BlessCountUp",
|
|
12
|
+
__name: "BlessCountUp",
|
|
13
|
+
props: {
|
|
14
|
+
value: {},
|
|
15
|
+
duration: { default: 800 },
|
|
16
|
+
locale: {},
|
|
17
|
+
options: {},
|
|
18
|
+
appear: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: !0
|
|
21
|
+
},
|
|
22
|
+
odometer: { type: Boolean }
|
|
23
|
+
},
|
|
24
|
+
setup(o) {
|
|
25
|
+
let b = o, x = f(b.appear ? 0 : b.value), S = n(() => new Intl.NumberFormat(b.locale, b.options)), C = n(() => {
|
|
26
|
+
let e = b.options ?? {};
|
|
27
|
+
return e.style === "currency" || e.style === "percent" || e.minimumFractionDigits != null || e.maximumFractionDigits != null || !Number.isInteger(b.value) ? S.value.resolvedOptions().maximumFractionDigits ?? 0 : 0;
|
|
28
|
+
}), w = (e) => S.value.format(e), T = (e) => Math.round(e * 10 ** C.value) / 10 ** C.value, E = n(() => w(b.value)), D = n(() => Array.from(w(x.value))), O = 0;
|
|
29
|
+
function k(t) {
|
|
30
|
+
cancelAnimationFrame(O);
|
|
31
|
+
let n = x.value;
|
|
32
|
+
if (e() || !b.duration || n === t) {
|
|
33
|
+
x.value = t;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
let r = performance.now(), i = (e) => {
|
|
37
|
+
let a = Math.min(1, (e - r) / b.duration);
|
|
38
|
+
x.value = T(n + (t - n) * (1 - (1 - a) ** 3)), a < 1 ? O = requestAnimationFrame(i) : x.value = t;
|
|
39
|
+
};
|
|
40
|
+
O = requestAnimationFrame(i);
|
|
41
|
+
}
|
|
42
|
+
return u(() => b.appear && k(b.value)), h(() => b.value, (e) => k(e)), l(() => cancelAnimationFrame(O)), (e, n) => (d(), r("span", { class: s(["bless-countup", { "bless-countup--odometer": o.odometer }]) }, [i("span", g, [o.odometer ? (d(!0), r(t, { key: 0 }, p(D.value, (e, n) => (d(), r(t, { key: n }, [/\d/.test(e) ? (d(), r("span", _, [i("span", {
|
|
43
|
+
class: "bless-countup__reel",
|
|
44
|
+
style: c({ "--bless-digit": e })
|
|
45
|
+
}, [(d(), r(t, null, p(10, (e) => i("i", { key: e }, m(e - 1), 1)), 64))], 4)])) : (d(), r("span", v, m(e), 1))], 64))), 128)) : (d(), r(t, { key: 1 }, [a(m(w(x.value)), 1)], 64))]), i("span", y, m(E.value), 1)], 2));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
//#endregion
|
|
49
|
+
export { b as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.bless-cropper{font-family:var(--bless-font-sans);font-size:var(--bless-text-sm);color:var(--bless-color-text);position:relative}.bless-cropper__stage{touch-action:none;-webkit-user-select:none;user-select:none;background:var(--bless-color-surface);position:relative;overflow:hidden}.bless-cropper__canvas{width:100%;height:auto;display:block}.bless-cropper__frame{box-sizing:border-box;border:2px solid var(--bless-color-bg);outline:1px solid var(--bless-color-text);box-shadow:0 0 0 9999px color-mix(in srgb, var(--bless-color-bg) 55%, transparent);cursor:move;touch-action:none;position:absolute}.bless-cropper__frame:focus-visible{outline:2px solid var(--bless-color-accent)}.bless-cropper__handle{background:var(--bless-color-bg);border:1px solid var(--bless-color-text);touch-action:none;width:12px;height:12px;position:absolute}.bless-cropper__handle--nw{cursor:nwse-resize;inset-block-start:-7px;inset-inline-start:-7px}.bless-cropper__handle--ne{cursor:nesw-resize;inset-block-start:-7px;inset-inline-end:-7px}.bless-cropper__handle--se{cursor:nwse-resize;inset-block-end:-7px;inset-inline-end:-7px}.bless-cropper__handle--sw{cursor:nesw-resize;inset-block-end:-7px;inset-inline-start:-7px}.bless-cropper__handle--n,.bless-cropper__handle--s{cursor:ns-resize;inset-inline-start:calc(50% - 6px)}.bless-cropper__handle--n{inset-block-start:-7px}.bless-cropper__handle--s{inset-block-end:-7px}.bless-cropper__handle--e,.bless-cropper__handle--w{cursor:ew-resize;inset-block-start:calc(50% - 6px)}.bless-cropper__handle--e{inset-inline-end:-7px}.bless-cropper__handle--w{inset-inline-start:-7px}.bless-cropper__foot{justify-content:space-between;align-items:center;gap:var(--bless-space-2);margin-top:var(--bless-space-2);color:var(--bless-color-text-muted);font-size:var(--bless-text-xs);display:flex}.bless-cropper__controls{gap:var(--bless-space-1);display:inline-flex}.bless-cropper__error{color:var(--bless-color-danger-text);margin:0}.bless-cropper__live{clip-path:inset(50%);width:1px;height:1px;position:absolute;overflow:hidden}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CropBox } from '../composables/cropBox';
|
|
2
|
+
export interface BlessCropRect {
|
|
3
|
+
/** pixels of the full-size image after `rotation` has been applied */
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
rotation: 0 | 90 | 180 | 270;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
12
|
+
declare const __VLS_export: import('vue').DefineComponent<{
|
|
13
|
+
src: string;
|
|
14
|
+
/** width / height of the result, e.g. `1` or `16 / 9`; leave out to crop freely */
|
|
15
|
+
aspect?: number;
|
|
16
|
+
/** `anonymous` lets `toBlob` read images from another origin that sends CORS headers */
|
|
17
|
+
crossorigin?: "anonymous" | "use-credentials";
|
|
18
|
+
/** show the rotate buttons */
|
|
19
|
+
controls?: boolean;
|
|
20
|
+
label?: string;
|
|
21
|
+
} & {
|
|
22
|
+
modelValue?: BlessCropRect | null;
|
|
23
|
+
}, {
|
|
24
|
+
toBlob: (o?: {
|
|
25
|
+
type?: string;
|
|
26
|
+
quality?: number;
|
|
27
|
+
maxWidth?: number;
|
|
28
|
+
}) => Promise<Blob | null>;
|
|
29
|
+
rotate: (d: 90 | -90) => 0 | 90 | 180 | 270;
|
|
30
|
+
reset: () => CropBox;
|
|
31
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
32
|
+
"update:modelValue": (value: BlessCropRect | null) => any;
|
|
33
|
+
error: () => any;
|
|
34
|
+
ready: () => any;
|
|
35
|
+
}, string, import('vue').PublicProps, Readonly<{
|
|
36
|
+
src: string;
|
|
37
|
+
/** width / height of the result, e.g. `1` or `16 / 9`; leave out to crop freely */
|
|
38
|
+
aspect?: number;
|
|
39
|
+
/** `anonymous` lets `toBlob` read images from another origin that sends CORS headers */
|
|
40
|
+
crossorigin?: "anonymous" | "use-credentials";
|
|
41
|
+
/** show the rotate buttons */
|
|
42
|
+
controls?: boolean;
|
|
43
|
+
label?: string;
|
|
44
|
+
} & {
|
|
45
|
+
modelValue?: BlessCropRect | null;
|
|
46
|
+
}> & Readonly<{
|
|
47
|
+
"onUpdate:modelValue"?: ((value: BlessCropRect | null) => any) | undefined;
|
|
48
|
+
onError?: (() => any) | undefined;
|
|
49
|
+
onReady?: (() => any) | undefined;
|
|
50
|
+
}>, {
|
|
51
|
+
label: string;
|
|
52
|
+
controls: boolean;
|
|
53
|
+
crossorigin: "anonymous" | "use-credentials";
|
|
54
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import e from "./BlessButton.js";
|
|
2
|
+
import { initialBox as t, moveBox as n, resizeBox as r, scaleBox as i } from "../composables/cropBox.js";
|
|
3
|
+
import { Fragment as a, computed as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, defineComponent as f, mergeModels as p, nextTick as m, normalizeClass as h, normalizeStyle as ee, onBeforeUnmount as g, openBlock as _, ref as v, renderList as y, toDisplayString as b, unref as x, useId as S, useModel as C, watch as w, withCtx as T } from "vue";
|
|
4
|
+
//#region src/components/BlessCropper.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var te = { class: "bless-cropper" }, ne = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "bless-cropper__error",
|
|
8
|
+
role: "alert"
|
|
9
|
+
}, re = ["aria-busy"], E = ["aria-label", "aria-describedby"], D = ["onPointerdown"], O = {
|
|
10
|
+
key: 2,
|
|
11
|
+
class: "bless-cropper__foot"
|
|
12
|
+
}, k = ["id"], ie = {
|
|
13
|
+
key: 0,
|
|
14
|
+
class: "bless-cropper__controls"
|
|
15
|
+
}, ae = {
|
|
16
|
+
class: "bless-cropper__live",
|
|
17
|
+
"aria-live": "polite"
|
|
18
|
+
}, A = /*@__PURE__*/ f({
|
|
19
|
+
name: "BlessCropper",
|
|
20
|
+
__name: "BlessCropper",
|
|
21
|
+
props: /*@__PURE__*/ p({
|
|
22
|
+
src: {},
|
|
23
|
+
aspect: {},
|
|
24
|
+
crossorigin: { default: "anonymous" },
|
|
25
|
+
controls: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: !0
|
|
28
|
+
},
|
|
29
|
+
label: { default: "Crop area" }
|
|
30
|
+
}, {
|
|
31
|
+
modelValue: { default: null },
|
|
32
|
+
modelModifiers: {}
|
|
33
|
+
}),
|
|
34
|
+
emits: /*@__PURE__*/ p(["ready", "error"], ["update:modelValue"]),
|
|
35
|
+
setup(f, { expose: p, emit: A }) {
|
|
36
|
+
let j = f, M = C(f, "modelValue"), N = A, P = S(), F = v(), I = v(), L = v(null), R = v(!1), z = v(0), B = v({
|
|
37
|
+
l: 0,
|
|
38
|
+
t: 0,
|
|
39
|
+
r: 1,
|
|
40
|
+
b: 1
|
|
41
|
+
}), V = v(""), H = o(() => {
|
|
42
|
+
let e = L.value;
|
|
43
|
+
return e ? z.value % 180 ? {
|
|
44
|
+
w: e.naturalHeight,
|
|
45
|
+
h: e.naturalWidth
|
|
46
|
+
} : {
|
|
47
|
+
w: e.naturalWidth,
|
|
48
|
+
h: e.naturalHeight
|
|
49
|
+
} : {
|
|
50
|
+
w: 0,
|
|
51
|
+
h: 0
|
|
52
|
+
};
|
|
53
|
+
}), U = o(() => j.aspect && H.value.w ? j.aspect * H.value.h / H.value.w : 0), W = o(() => {
|
|
54
|
+
let { w: e, h: t } = H.value;
|
|
55
|
+
if (!e) return null;
|
|
56
|
+
let n = B.value;
|
|
57
|
+
return {
|
|
58
|
+
x: Math.round(n.l * e),
|
|
59
|
+
y: Math.round(n.t * t),
|
|
60
|
+
width: Math.round((n.r - n.l) * e),
|
|
61
|
+
height: Math.round((n.b - n.t) * t),
|
|
62
|
+
rotation: z.value
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
w(W, (e) => e && (M.value = e));
|
|
66
|
+
function G(e, t) {
|
|
67
|
+
let n = L.value, r = e.getContext("2d");
|
|
68
|
+
n && r && (e.width = Math.max(1, Math.round(H.value.w * t)), e.height = Math.max(1, Math.round(H.value.h * t)), r.translate(e.width / 2, e.height / 2), r.rotate(z.value * Math.PI / 180), r.drawImage(n, -n.naturalWidth * t / 2, -n.naturalHeight * t / 2, n.naturalWidth * t, n.naturalHeight * t));
|
|
69
|
+
}
|
|
70
|
+
let K = () => B.value = t(U.value);
|
|
71
|
+
w(() => [L.value, z.value], () => m(() => I.value && G(I.value, Math.min(1, 1024 / Math.max(H.value.w, H.value.h))))), w(() => [
|
|
72
|
+
L.value,
|
|
73
|
+
z.value,
|
|
74
|
+
j.aspect
|
|
75
|
+
], K);
|
|
76
|
+
let q;
|
|
77
|
+
w(() => [j.src, j.crossorigin], ([e, t]) => {
|
|
78
|
+
L.value = null, R.value = !1;
|
|
79
|
+
let n = new Image();
|
|
80
|
+
q = n, n.crossOrigin = t, n.onload = () => {
|
|
81
|
+
q === n && (L.value = n, N("ready"));
|
|
82
|
+
}, n.onerror = () => {
|
|
83
|
+
q === n && (R.value = !0, N("error"));
|
|
84
|
+
}, n.src = e;
|
|
85
|
+
}, { immediate: !0 }), g(() => q = void 0);
|
|
86
|
+
let J = (e) => z.value = (z.value + e + 360) % 360, Y = null, X = (e) => {
|
|
87
|
+
let t = F.value.getBoundingClientRect();
|
|
88
|
+
return {
|
|
89
|
+
x: (e.clientX - t.left) / t.width,
|
|
90
|
+
y: (e.clientY - t.top) / t.height
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
function Z(e, t) {
|
|
94
|
+
t.button || (t.currentTarget.setPointerCapture?.(t.pointerId), t.stopPropagation(), Y = {
|
|
95
|
+
h: e,
|
|
96
|
+
box: B.value,
|
|
97
|
+
...X(t)
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function Q(e) {
|
|
101
|
+
if (!Y) return;
|
|
102
|
+
let t = X(e);
|
|
103
|
+
B.value = Y.h ? r(Y.box, Y.h, t.x, t.y, U.value) : n(Y.box, t.x - Y.x, t.y - Y.y);
|
|
104
|
+
}
|
|
105
|
+
let $ = () => Y = null;
|
|
106
|
+
function oe(e) {
|
|
107
|
+
let t = e.shiftKey ? .1 : .01, r = {
|
|
108
|
+
ArrowLeft: [-t, 0],
|
|
109
|
+
ArrowRight: [t, 0],
|
|
110
|
+
ArrowUp: [0, -t],
|
|
111
|
+
ArrowDown: [0, t]
|
|
112
|
+
};
|
|
113
|
+
if (r[e.key]) B.value = n(B.value, ...r[e.key]);
|
|
114
|
+
else if (e.key === "+" || e.key === "=") B.value = i(B.value, t * 2);
|
|
115
|
+
else if (e.key === "-" || e.key === "_") B.value = i(B.value, -t * 2);
|
|
116
|
+
else return;
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
let a = W.value;
|
|
119
|
+
V.value = `${a.width} by ${a.height} pixels, from ${a.x}, ${a.y}`;
|
|
120
|
+
}
|
|
121
|
+
let se = o(() => U.value ? [
|
|
122
|
+
"nw",
|
|
123
|
+
"ne",
|
|
124
|
+
"se",
|
|
125
|
+
"sw"
|
|
126
|
+
] : [
|
|
127
|
+
"nw",
|
|
128
|
+
"n",
|
|
129
|
+
"ne",
|
|
130
|
+
"e",
|
|
131
|
+
"se",
|
|
132
|
+
"s",
|
|
133
|
+
"sw",
|
|
134
|
+
"w"
|
|
135
|
+
]), ce = o(() => ({
|
|
136
|
+
left: `${B.value.l * 100}%`,
|
|
137
|
+
top: `${B.value.t * 100}%`,
|
|
138
|
+
width: `${(B.value.r - B.value.l) * 100}%`,
|
|
139
|
+
height: `${(B.value.b - B.value.t) * 100}%`
|
|
140
|
+
}));
|
|
141
|
+
function le(e = {}) {
|
|
142
|
+
let t = W.value;
|
|
143
|
+
if (!t || !L.value) return Promise.resolve(null);
|
|
144
|
+
let n = document.createElement("canvas");
|
|
145
|
+
G(n, 1);
|
|
146
|
+
let r = e.maxWidth && t.width > e.maxWidth ? e.maxWidth / t.width : 1, i = document.createElement("canvas");
|
|
147
|
+
return i.width = Math.max(1, Math.round(t.width * r)), i.height = Math.max(1, Math.round(t.height * r)), i.getContext("2d")?.drawImage(n, t.x, t.y, t.width, t.height, 0, 0, i.width, i.height), new Promise((t) => i.toBlob(t, e.type ?? "image/png", e.quality));
|
|
148
|
+
}
|
|
149
|
+
return p({
|
|
150
|
+
toBlob: le,
|
|
151
|
+
rotate: J,
|
|
152
|
+
reset: K
|
|
153
|
+
}), (t, n) => (_(), c("div", te, [
|
|
154
|
+
R.value ? (_(), c("p", ne, "The image could not be loaded.")) : (_(), c("div", {
|
|
155
|
+
key: 1,
|
|
156
|
+
ref_key: "stage",
|
|
157
|
+
ref: F,
|
|
158
|
+
class: "bless-cropper__stage",
|
|
159
|
+
"aria-busy": !L.value
|
|
160
|
+
}, [l("canvas", {
|
|
161
|
+
ref_key: "canvas",
|
|
162
|
+
ref: I,
|
|
163
|
+
class: "bless-cropper__canvas",
|
|
164
|
+
"aria-hidden": "true"
|
|
165
|
+
}, null, 512), L.value ? (_(), c("div", {
|
|
166
|
+
key: 0,
|
|
167
|
+
class: "bless-cropper__frame",
|
|
168
|
+
tabindex: "0",
|
|
169
|
+
role: "group",
|
|
170
|
+
"aria-label": f.label,
|
|
171
|
+
"aria-describedby": `${x(P)}-hint`,
|
|
172
|
+
style: ee(ce.value),
|
|
173
|
+
onPointerdown: n[0] ||= (e) => Z(null, e),
|
|
174
|
+
onPointermove: Q,
|
|
175
|
+
onPointerup: $,
|
|
176
|
+
onPointercancel: $,
|
|
177
|
+
onKeydown: oe
|
|
178
|
+
}, [(_(!0), c(a, null, y(se.value, (e) => (_(), c("span", {
|
|
179
|
+
key: e,
|
|
180
|
+
class: h(["bless-cropper__handle", `bless-cropper__handle--${e}`]),
|
|
181
|
+
"aria-hidden": "true",
|
|
182
|
+
onPointerdown: (t) => Z(e, t),
|
|
183
|
+
onPointermove: Q,
|
|
184
|
+
onPointerup: $,
|
|
185
|
+
onPointercancel: $
|
|
186
|
+
}, null, 42, D))), 128))], 44, E)) : s("", !0)], 8, re)),
|
|
187
|
+
L.value ? (_(), c("div", O, [l("span", {
|
|
188
|
+
id: `${x(P)}-hint`,
|
|
189
|
+
class: "bless-cropper__readout"
|
|
190
|
+
}, b(W.value?.width) + " × " + b(W.value?.height) + " px · arrows move, + − resize", 9, k), f.controls ? (_(), c("span", ie, [d(e, {
|
|
191
|
+
size: "sm",
|
|
192
|
+
variant: "ghost",
|
|
193
|
+
"aria-label": "Rotate left",
|
|
194
|
+
onClick: n[1] ||= (e) => J(-90)
|
|
195
|
+
}, {
|
|
196
|
+
default: T(() => [...n[3] ||= [u("↺", -1)]]),
|
|
197
|
+
_: 1
|
|
198
|
+
}), d(e, {
|
|
199
|
+
size: "sm",
|
|
200
|
+
variant: "ghost",
|
|
201
|
+
"aria-label": "Rotate right",
|
|
202
|
+
onClick: n[2] ||= (e) => J(90)
|
|
203
|
+
}, {
|
|
204
|
+
default: T(() => [...n[4] ||= [u("↻", -1)]]),
|
|
205
|
+
_: 1
|
|
206
|
+
})])) : s("", !0)])) : s("", !0),
|
|
207
|
+
l("span", ae, b(V.value), 1)
|
|
208
|
+
]));
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
//#endregion
|
|
212
|
+
export { A as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.bless-diff{min-width:0;max-width:100%;font-family:var(--bless-font-sans);font-size:var(--bless-text-sm);color:var(--bless-color-text);border:var(--bless-border-width) solid var(--bless-color-border);margin:0}.bless-diff__head{justify-content:space-between;gap:var(--bless-space-3);padding:var(--bless-space-2) var(--bless-space-3);background:var(--bless-color-surface);border-bottom:var(--bless-border-width) solid var(--bless-color-border);display:flex}.bless-diff__count{gap:var(--bless-space-2);font-variant-numeric:tabular-nums;display:inline-flex}.bless-diff__plus{color:var(--bless-color-text);font-weight:600}.bless-diff__minus{color:var(--bless-color-danger-text);font-weight:600}.bless-diff__sr{clip-path:inset(50%);width:1px;height:1px;position:absolute;overflow:hidden}.bless-diff__scroll{overflow:auto}.bless-diff__scroll:focus-visible{outline:2px solid var(--bless-color-accent);outline-offset:-2px}.bless-diff__table{border-collapse:collapse;width:100%;font-family:var(--bless-font-mono,ui-monospace, monospace);font-size:var(--bless-text-sm)}.bless-diff .bless-diff__cols th{padding:var(--bless-space-1) var(--bless-space-3);text-align:start;font-family:var(--bless-font-sans);color:var(--bless-color-text-muted);font-weight:600}.bless-diff .bless-diff__table :is(td,th){padding:0 var(--bless-space-2);vertical-align:top;background:0 0;border:0}.bless-diff .bless-diff__table tr{background:0 0}.bless-diff__no{text-align:end;width:1%;min-width:3ch;color:var(--bless-color-text-muted);-webkit-user-select:none;user-select:none}.bless-diff__sign{-webkit-user-select:none;user-select:none;width:1%;font-weight:700}.bless-diff__text{white-space:pre}.bless-diff .bless-diff__row--add>td,.bless-diff .bless-diff__table td.bless-diff__cell--add{background:color-mix(in srgb, var(--bless-color-success) 24%, var(--bless-color-bg))}.bless-diff .bless-diff__row--del>td,.bless-diff .bless-diff__table td.bless-diff__cell--del{background:color-mix(in srgb, var(--bless-color-danger) 18%, var(--bless-color-bg))}.bless-diff .bless-diff__row--add>.bless-diff__no,.bless-diff .bless-diff__row--del>.bless-diff__no,.bless-diff .bless-diff__table td.bless-diff__cell--add+.bless-diff__no{color:var(--bless-color-text)}.bless-diff .bless-diff__table td.bless-diff__cell--empty{background:var(--bless-color-surface)}.bless-diff--split .bless-diff__text{border-inline-start:var(--bless-border-width) solid var(--bless-color-border);width:50%}.bless-diff .bless-diff__table .bless-diff__fold td{padding:var(--bless-space-1) var(--bless-space-3);background:var(--bless-color-surface);border-block:var(--bless-border-width) solid var(--bless-color-border)}.bless-diff__fold button{color:var(--bless-color-text-muted);font:inherit;font-family:var(--bless-font-sans);cursor:pointer;background:0 0;border:0;text-decoration:underline}.bless-diff__fold button:focus-visible{outline:2px solid var(--bless-color-accent)}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
/** the old text */
|
|
3
|
+
a: string;
|
|
4
|
+
/** the new text */
|
|
5
|
+
b: string;
|
|
6
|
+
mode?: "inline" | "split";
|
|
7
|
+
/** unchanged lines kept around each change; the rest fold away. Leave out to show everything */
|
|
8
|
+
context?: number;
|
|
9
|
+
lineNumbers?: boolean;
|
|
10
|
+
labelA?: string;
|
|
11
|
+
labelB?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
};
|
|
14
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
15
|
+
label: string;
|
|
16
|
+
mode: "inline" | "split";
|
|
17
|
+
lineNumbers: boolean;
|
|
18
|
+
labelA: string;
|
|
19
|
+
labelB: string;
|
|
20
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
declare const _default: typeof __VLS_export;
|
|
22
|
+
export default _default;
|