blessing-ui 0.2.0 → 0.3.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 (133) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +137 -125
  3. package/dist/blessing-ui.css +38 -2
  4. package/dist/components/BlessAnnotator.css +1 -0
  5. package/dist/components/BlessAnnotator.js +6 -0
  6. package/dist/components/BlessAnnotator.vue.d.ts +71 -0
  7. package/dist/components/BlessAnnotator.vue_vue_type_script_setup_true_lang.js +264 -0
  8. package/dist/components/BlessAttachment.vue.d.ts +4 -1
  9. package/dist/components/BlessAttachment.vue_vue_type_script_setup_true_lang.js +3 -2
  10. package/dist/components/BlessCalendar.vue.d.ts +4 -0
  11. package/dist/components/BlessCalendar.vue_vue_type_script_setup_true_lang.js +65 -60
  12. package/dist/components/BlessCarousel.vue.d.ts +3 -0
  13. package/dist/components/BlessCarousel.vue_vue_type_script_setup_true_lang.js +10 -9
  14. package/dist/components/BlessCoachmark.css +1 -0
  15. package/dist/components/BlessCoachmark.js +6 -0
  16. package/dist/components/BlessCoachmark.vue.d.ts +40 -0
  17. package/dist/components/BlessCoachmark.vue_vue_type_script_setup_true_lang.js +74 -0
  18. package/dist/components/BlessCodeBlock.vue.d.ts +10 -0
  19. package/dist/components/BlessCodeBlock.vue_vue_type_script_setup_true_lang.js +39 -33
  20. package/dist/components/BlessCombobox.vue.d.ts +2 -0
  21. package/dist/components/BlessCombobox.vue_vue_type_script_setup_true_lang.js +3 -2
  22. package/dist/components/BlessCommand.css +1 -1
  23. package/dist/components/BlessCommand.vue.d.ts +26 -0
  24. package/dist/components/BlessCommand.vue_vue_type_script_setup_true_lang.js +137 -70
  25. package/dist/components/BlessConfetti.css +1 -0
  26. package/dist/components/BlessConfetti.js +6 -0
  27. package/dist/components/BlessConfetti.vue.d.ts +40 -0
  28. package/dist/components/BlessConfetti.vue_vue_type_script_setup_true_lang.js +77 -0
  29. package/dist/components/BlessCropper.vue.d.ts +16 -0
  30. package/dist/components/BlessCropper.vue_vue_type_script_setup_true_lang.js +47 -39
  31. package/dist/components/BlessDataTable.vue.d.ts +6 -0
  32. package/dist/components/BlessDataTable.vue_vue_type_script_setup_true_lang.js +56 -42
  33. package/dist/components/BlessDataView.vue.d.ts +7 -0
  34. package/dist/components/BlessDataView.vue_vue_type_script_setup_true_lang.js +38 -31
  35. package/dist/components/BlessDatePicker.vue.d.ts +3 -0
  36. package/dist/components/BlessDatePicker.vue_vue_type_script_setup_true_lang.js +46 -45
  37. package/dist/components/BlessDock.css +1 -0
  38. package/dist/components/BlessDock.js +6 -0
  39. package/dist/components/BlessDock.vue.d.ts +55 -0
  40. package/dist/components/BlessDock.vue_vue_type_script_setup_true_lang.js +100 -0
  41. package/dist/components/BlessEditor.vue.d.ts +2 -0
  42. package/dist/components/BlessEditor.vue_vue_type_script_setup_true_lang.js +23 -22
  43. package/dist/components/BlessFileInput.vue.d.ts +2 -0
  44. package/dist/components/BlessFileInput.vue_vue_type_script_setup_true_lang.js +3 -2
  45. package/dist/components/BlessFormula.css +1 -0
  46. package/dist/components/BlessFormula.js +6 -0
  47. package/dist/components/BlessFormula.vue.d.ts +53 -0
  48. package/dist/components/BlessFormula.vue_vue_type_script_setup_true_lang.js +111 -0
  49. package/dist/components/BlessGantt.vue.d.ts +12 -0
  50. package/dist/components/BlessGantt.vue_vue_type_script_setup_true_lang.js +74 -68
  51. package/dist/components/BlessInfiniteCanvas.css +1 -0
  52. package/dist/components/BlessInfiniteCanvas.js +6 -0
  53. package/dist/components/BlessInfiniteCanvas.vue.d.ts +91 -0
  54. package/dist/components/BlessInfiniteCanvas.vue_vue_type_script_setup_true_lang.js +232 -0
  55. package/dist/components/BlessInputNumber.vue.d.ts +5 -0
  56. package/dist/components/BlessInputNumber.vue_vue_type_script_setup_true_lang.js +39 -34
  57. package/dist/components/BlessKanban.vue.d.ts +12 -0
  58. package/dist/components/BlessKanban.vue_vue_type_script_setup_true_lang.js +127 -97
  59. package/dist/components/BlessLoadingBar.vue.d.ts +2 -0
  60. package/dist/components/BlessLoadingBar.vue_vue_type_script_setup_true_lang.js +8 -3
  61. package/dist/components/BlessMarquee.vue.d.ts +4 -0
  62. package/dist/components/BlessMarquee.vue_vue_type_script_setup_true_lang.js +32 -27
  63. package/dist/components/BlessNodeGraph.css +1 -0
  64. package/dist/components/BlessNodeGraph.js +6 -0
  65. package/dist/components/BlessNodeGraph.vue.d.ts +110 -0
  66. package/dist/components/BlessNodeGraph.vue_vue_type_script_setup_true_lang.js +321 -0
  67. package/dist/components/BlessOnboardingChecklist.css +1 -0
  68. package/dist/components/BlessOnboardingChecklist.js +6 -0
  69. package/dist/components/BlessOnboardingChecklist.vue.d.ts +72 -0
  70. package/dist/components/BlessOnboardingChecklist.vue_vue_type_script_setup_true_lang.js +157 -0
  71. package/dist/components/BlessOrderList.vue.d.ts +5 -0
  72. package/dist/components/BlessOrderList.vue_vue_type_script_setup_true_lang.js +62 -56
  73. package/dist/components/BlessPagination.vue.d.ts +2 -0
  74. package/dist/components/BlessPagination.vue_vue_type_script_setup_true_lang.js +2 -1
  75. package/dist/components/BlessPickList.vue.d.ts +5 -0
  76. package/dist/components/BlessPickList.vue_vue_type_script_setup_true_lang.js +55 -49
  77. package/dist/components/BlessRangeCalendar.css +1 -0
  78. package/dist/components/BlessRangeCalendar.js +6 -0
  79. package/dist/components/BlessRangeCalendar.vue.d.ts +51 -0
  80. package/dist/components/BlessRangeCalendar.vue_vue_type_script_setup_true_lang.js +217 -0
  81. package/dist/components/BlessScheduler.css +1 -0
  82. package/dist/components/BlessScheduler.js +6 -0
  83. package/dist/components/BlessScheduler.vue.d.ts +95 -0
  84. package/dist/components/BlessScheduler.vue_vue_type_script_setup_true_lang.js +347 -0
  85. package/dist/components/BlessShortcutRecorder.vue.d.ts +10 -0
  86. package/dist/components/BlessShortcutRecorder.vue_vue_type_script_setup_true_lang.js +50 -40
  87. package/dist/components/BlessSignaturePad.vue.d.ts +1 -1
  88. package/dist/components/BlessSliderCaptcha.vue.d.ts +5 -0
  89. package/dist/components/BlessSliderCaptcha.vue_vue_type_script_setup_true_lang.js +89 -84
  90. package/dist/components/BlessSortable.css +1 -1
  91. package/dist/components/BlessSortable.vue.d.ts +19 -1
  92. package/dist/components/BlessSortable.vue_vue_type_script_setup_true_lang.js +103 -55
  93. package/dist/components/BlessSparkline.css +1 -0
  94. package/dist/components/BlessSparkline.js +6 -0
  95. package/dist/components/BlessSparkline.vue.d.ts +28 -0
  96. package/dist/components/BlessSparkline.vue_vue_type_script_setup_true_lang.js +107 -0
  97. package/dist/components/BlessSteps.vue.d.ts +2 -0
  98. package/dist/components/BlessSteps.vue_vue_type_script_setup_true_lang.js +3 -2
  99. package/dist/components/BlessSwipeDeck.vue.d.ts +1 -1
  100. package/dist/components/BlessSwipeDeck.vue_vue_type_script_setup_true_lang.js +2 -1
  101. package/dist/components/BlessTimer.vue.d.ts +18 -0
  102. package/dist/components/BlessTimer.vue_vue_type_script_setup_true_lang.js +52 -43
  103. package/dist/components/BlessTour.vue.d.ts +1 -0
  104. package/dist/components/BlessTour.vue_vue_type_script_setup_true_lang.js +48 -42
  105. package/dist/components/BlessTreemap.css +1 -0
  106. package/dist/components/BlessTreemap.js +6 -0
  107. package/dist/components/BlessTreemap.vue.d.ts +46 -0
  108. package/dist/components/BlessTreemap.vue_vue_type_script_setup_true_lang.js +137 -0
  109. package/dist/components/BlessUploader.vue.d.ts +11 -0
  110. package/dist/components/BlessUploader.vue_vue_type_script_setup_true_lang.js +80 -69
  111. package/dist/composables/annotate.d.ts +35 -0
  112. package/dist/composables/annotate.js +33 -0
  113. package/dist/composables/canvasView.d.ts +21 -0
  114. package/dist/composables/canvasView.js +23 -0
  115. package/dist/composables/confetti.d.ts +32 -0
  116. package/dist/composables/confetti.js +23 -0
  117. package/dist/composables/dayBlocks.d.ts +11 -0
  118. package/dist/composables/dayBlocks.js +26 -0
  119. package/dist/composables/formula.d.ts +28 -0
  120. package/dist/composables/formula.js +161 -0
  121. package/dist/composables/graph.d.ts +19 -0
  122. package/dist/composables/graph.js +16 -0
  123. package/dist/composables/schedule.d.ts +27 -0
  124. package/dist/composables/schedule.js +54 -0
  125. package/dist/composables/treemap.d.ts +23 -0
  126. package/dist/composables/treemap.js +77 -0
  127. package/dist/composables/useAutoScroll.d.ts +15 -0
  128. package/dist/composables/useAutoScroll.js +32 -0
  129. package/dist/composables/useSortable.d.ts +42 -2
  130. package/dist/composables/useSortable.js +87 -14
  131. package/dist/index.d.ts +25 -1
  132. package/dist/index.js +78 -63
  133. package/package.json +4 -2
@@ -0,0 +1,111 @@
1
+ import { evaluate as e, usedNames as t } from "../composables/formula.js";
2
+ import { Fragment as n, computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, defineComponent as s, mergeModels as c, nextTick as l, normalizeClass as u, onMounted as d, openBlock as f, ref as p, renderList as m, toDisplayString as h, unref as g, useId as _, useModel as v, vModelText as y, watch as b, withDirectives as x } from "vue";
3
+ //#region src/components/BlessFormula.vue?vue&type=script&setup=true&lang.ts
4
+ var S = ["for"], C = [
5
+ "id",
6
+ "placeholder",
7
+ "disabled",
8
+ "aria-invalid",
9
+ "aria-describedby"
10
+ ], w = ["aria-label"], T = [
11
+ "aria-pressed",
12
+ "title",
13
+ "disabled",
14
+ "onClick"
15
+ ], E = ["id"], D = { class: "bless-formula__error" }, O = {
16
+ key: 1,
17
+ class: "bless-formula__value"
18
+ }, k = /*@__PURE__*/ s({
19
+ name: "BlessFormula",
20
+ __name: "BlessFormula",
21
+ props: /*@__PURE__*/ c({
22
+ variables: { default: () => [] },
23
+ functions: {},
24
+ label: { default: "Formula" },
25
+ placeholder: { default: "price * qty" },
26
+ disabled: { type: Boolean },
27
+ locale: {},
28
+ labels: {}
29
+ }, {
30
+ modelValue: { default: "" },
31
+ modelModifiers: {}
32
+ }),
33
+ emits: /*@__PURE__*/ c(["result"], ["update:modelValue"]),
34
+ setup(s, { emit: c }) {
35
+ let k = s, A = v(s, "modelValue"), j = c, M = r(() => ({
36
+ insert: "Insert a value",
37
+ result: (e) => `= ${e}`,
38
+ use: (e) => `Use “${e}”`,
39
+ error: (e) => {
40
+ switch (e.code) {
41
+ case "unexpected": return e.name ? `Unexpected “${e.name}” at position ${e.pos + 1}` : "The formula ends too soon";
42
+ case "unclosed": return "A bracket is not closed";
43
+ case "unknown-variable": return `Unknown value “${e.name}”${e.suggestion ? ` — did you mean “${e.suggestion}”?` : ""}`;
44
+ case "unknown-function": return `Unknown function “${e.name}”${e.suggestion ? ` — did you mean “${e.suggestion}”?` : ""}`;
45
+ case "arity": return `${e.name} needs a value to work on`;
46
+ case "divide-by-zero": return "Division by zero";
47
+ default: return "The result is not a number";
48
+ }
49
+ },
50
+ ...k.labels
51
+ })), N = _(), P = p(), F = r(() => Object.fromEntries(k.variables.map((e) => [e.name, e.value]))), I = r(() => e(A.value, F.value, k.functions)), L = r(() => !I.value.ok && I.value.error.code === "empty"), R = r(() => I.value.ok || L.value ? null : I.value.error), z = r(() => I.value.ok ? new Intl.NumberFormat(k.locale, { maximumFractionDigits: 6 }).format(I.value.value) : ""), B = r(() => new Set(t(A.value))), V = () => j("result", I.value.ok ? I.value.value : null);
52
+ d(V), b(I, V);
53
+ async function H(e) {
54
+ let t = P.value, n = A.value, r = t?.selectionStart ?? n.length, i = t?.selectionEnd ?? n.length, a = /[A-Za-z0-9_.)]/, o = r > 0 && a.test(n[r - 1]) ? " " : "", s = i < n.length && a.test(n[i]) ? " " : "";
55
+ A.value = n.slice(0, r) + o + e + s + n.slice(i);
56
+ let c = r + o.length + e.length;
57
+ await l(), t?.focus(), t?.setSelectionRange(c, c);
58
+ }
59
+ function U(e) {
60
+ A.value = A.value.slice(0, e.pos) + e.suggestion + A.value.slice(e.pos + e.length), l(() => P.value?.focus());
61
+ }
62
+ return (e, t) => (f(), a("div", { class: u(["bless-formula", { "bless-formula--bad": R.value }]) }, [
63
+ o("label", {
64
+ class: "bless-formula__label",
65
+ for: `${g(N)}-in`
66
+ }, h(s.label), 9, S),
67
+ x(o("input", {
68
+ id: `${g(N)}-in`,
69
+ ref_key: "input",
70
+ ref: P,
71
+ "onUpdate:modelValue": t[0] ||= (e) => A.value = e,
72
+ class: "bless-formula__input",
73
+ type: "text",
74
+ spellcheck: "false",
75
+ autocomplete: "off",
76
+ autocapitalize: "off",
77
+ placeholder: s.placeholder,
78
+ disabled: s.disabled,
79
+ "aria-invalid": R.value ? !0 : void 0,
80
+ "aria-describedby": `${g(N)}-out`
81
+ }, null, 8, C), [[y, A.value]]),
82
+ s.variables.length ? (f(), a("div", {
83
+ key: 0,
84
+ class: "bless-formula__vars",
85
+ role: "group",
86
+ "aria-label": M.value.insert
87
+ }, [(f(!0), a(n, null, m(s.variables, (e) => (f(), a("button", {
88
+ key: e.name,
89
+ type: "button",
90
+ class: "bless-formula__chip",
91
+ "aria-pressed": B.value.has(e.name),
92
+ title: `${e.name} = ${e.value}`,
93
+ disabled: s.disabled,
94
+ onClick: (t) => H(e.name)
95
+ }, h(e.label ?? e.name), 9, T))), 128))], 8, w)) : i("", !0),
96
+ o("p", {
97
+ id: `${g(N)}-out`,
98
+ class: "bless-formula__out",
99
+ role: "status",
100
+ "aria-live": "polite"
101
+ }, [R.value ? (f(), a(n, { key: 0 }, [o("span", D, h(M.value.error(R.value)), 1), R.value.suggestion ? (f(), a("button", {
102
+ key: 0,
103
+ type: "button",
104
+ class: "bless-formula__fix",
105
+ onClick: t[1] ||= (e) => U(R.value)
106
+ }, h(M.value.use(R.value.suggestion)), 1)) : i("", !0)], 64)) : I.value.ok ? (f(), a("span", O, h(M.value.result(z.value)), 1)) : i("", !0)], 8, E)
107
+ ], 2));
108
+ }
109
+ });
110
+ //#endregion
111
+ export { k as default };
@@ -24,6 +24,12 @@ declare const __VLS_export: import('vue').DefineComponent<{
24
24
  /** drag a bar to move it and its ends to resize it; Alt + arrows from the keyboard */
25
25
  editable?: boolean;
26
26
  label?: string;
27
+ /** the sentence read for a bar and the one announced after an edit; dates arrive formatted */
28
+ labels?: Partial<{
29
+ span: (task: string, from: string, to: string) => string;
30
+ done: (percent: number) => string;
31
+ after: (names: string[]) => string;
32
+ }>;
27
33
  } & {
28
34
  /** the schedule; with `editable`, moves and resizes come back through here */
29
35
  tasks: BlessGanttTask[];
@@ -49,6 +55,12 @@ declare const __VLS_export: import('vue').DefineComponent<{
49
55
  /** drag a bar to move it and its ends to resize it; Alt + arrows from the keyboard */
50
56
  editable?: boolean;
51
57
  label?: string;
58
+ /** the sentence read for a bar and the one announced after an edit; dates arrive formatted */
59
+ labels?: Partial<{
60
+ span: (task: string, from: string, to: string) => string;
61
+ done: (percent: number) => string;
62
+ after: (names: string[]) => string;
63
+ }>;
52
64
  } & {
53
65
  /** the schedule; with `editable`, moves and resizes come back through here */
54
66
  tasks: BlessGanttTask[];
@@ -1,13 +1,13 @@
1
1
  import { isoToday as e } from "../composables/date.js";
2
2
  import { Fragment as t, computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, mergeModels as s, normalizeClass as c, normalizeStyle as l, openBlock as u, ref as d, renderList as f, toDisplayString as p, useModel as m } from "vue";
3
3
  //#region src/components/BlessGantt.vue?vue&type=script&setup=true&lang.ts
4
- var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "bless-gantt__labels" }, te = ["title"], _ = {
4
+ var ee = ["aria-label"], h = { class: "bless-gantt__scroll" }, g = { class: "bless-gantt__labels" }, _ = ["title"], te = {
5
5
  class: "bless-gantt__head",
6
6
  "aria-hidden": "true"
7
- }, ne = { class: "bless-gantt__months" }, v = {
7
+ }, v = { class: "bless-gantt__months" }, y = {
8
8
  key: 0,
9
9
  class: "bless-gantt__days"
10
- }, re = ["width", "height"], y = ["d"], b = [
10
+ }, b = ["width", "height"], x = ["d"], ne = [
11
11
  "tabindex",
12
12
  "aria-label",
13
13
  "aria-pressed",
@@ -15,7 +15,7 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
15
15
  "onFocus",
16
16
  "onKeydown",
17
17
  "onPointerdown"
18
- ], x = ["onPointerdown"], ie = ["onPointerdown"], S = {
18
+ ], S = ["onPointerdown"], re = ["onPointerdown"], ie = {
19
19
  class: "bless-gantt__live",
20
20
  "aria-live": "polite"
21
21
  }, C = /*@__PURE__*/ o({
@@ -29,7 +29,8 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
29
29
  locale: {},
30
30
  labelWidth: { default: 160 },
31
31
  editable: { type: Boolean },
32
- label: { default: "Schedule" }
32
+ label: { default: "Schedule" },
33
+ labels: {}
33
34
  }, {
34
35
  tasks: { required: !0 },
35
36
  tasksModifiers: {},
@@ -38,82 +39,87 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
38
39
  }),
39
40
  emits: /*@__PURE__*/ s(["select", "change"], ["update:tasks", "update:selected"]),
40
41
  setup(o, { emit: s }) {
41
- let C = o, w = m(o, "tasks"), T = m(o, "selected"), E = s, D = 864e5, O = (e) => {
42
+ let C = o, w = n(() => ({
43
+ span: (e, t, n) => `${e}: ${t} to ${n}`,
44
+ done: (e) => `${e}% done`,
45
+ after: (e) => `after ${e.join(" and ")}`,
46
+ ...C.labels
47
+ })), T = m(o, "tasks"), E = m(o, "selected"), D = s, O = 864e5, k = (e) => {
42
48
  let [t, n, r] = e.split("-").map(Number);
43
- return Date.UTC(t, (n ?? 1) - 1, r ?? 1) / D;
44
- }, k = (e) => /* @__PURE__ */ new Date(e * D), A = (e) => k(e).toISOString().slice(0, 10), j = d(null), M = (e) => {
45
- let t = O(e.start), n = O(e.end), r = j.value;
49
+ return Date.UTC(t, (n ?? 1) - 1, r ?? 1) / O;
50
+ }, A = (e) => /* @__PURE__ */ new Date(e * O), j = (e) => A(e).toISOString().slice(0, 10), M = d(null), N = (e) => {
51
+ let t = k(e.start), n = k(e.end), r = M.value;
46
52
  return r && r.id === e.id && (r.mode === "move" ? (t = r.s + r.delta, n = r.e + r.delta) : r.mode === "start" ? t = Math.min(r.s + r.delta, r.e) : n = Math.max(r.e + r.delta, r.s)), {
47
53
  s: t,
48
54
  e: n
49
55
  };
50
- }, N = n(() => C.from ? O(C.from) : Math.min(...w.value.map((e) => M(e).s), O(e()))), P = n(() => C.to ? O(C.to) : Math.max(...w.value.map((e) => M(e).e), N.value)), F = n(() => Math.max(1, P.value - N.value + 1)), I = n(() => F.value * C.dayWidth), L = (e) => new Intl.DateTimeFormat(C.locale, {
56
+ }, P = n(() => C.from ? k(C.from) : Math.min(...T.value.map((e) => N(e).s), k(e()))), F = n(() => C.to ? k(C.to) : Math.max(...T.value.map((e) => N(e).e), P.value)), I = n(() => Math.max(1, F.value - P.value + 1)), L = n(() => I.value * C.dayWidth), R = (e) => new Intl.DateTimeFormat(C.locale, {
51
57
  ...e,
52
58
  timeZone: "UTC"
53
- }), R = n(() => L({
59
+ }), ae = n(() => R({
54
60
  month: "long",
55
61
  year: "numeric"
56
- })), z = n(() => L({
62
+ })), z = n(() => R({
57
63
  month: "short",
58
64
  day: "numeric"
59
- })), ae = n(() => {
65
+ })), oe = n(() => {
60
66
  let e = [];
61
- for (let t = 0; t < F.value; t++) {
62
- let n = k(N.value + t);
67
+ for (let t = 0; t < I.value; t++) {
68
+ let n = A(P.value + t);
63
69
  (!e.length || n.getUTCDate() === 1) && e.push({
64
- text: R.value.format(n),
70
+ text: ae.value.format(n),
65
71
  left: t * C.dayWidth,
66
72
  width: 0
67
73
  }), e.at(-1).width += C.dayWidth;
68
74
  }
69
75
  return e;
70
- }), B = n(() => C.dayWidth < 12 ? [] : Array.from({ length: F.value }, (e, t) => {
71
- let n = k(N.value + t), r = n.getUTCDay();
76
+ }), B = n(() => C.dayWidth < 12 ? [] : Array.from({ length: I.value }, (e, t) => {
77
+ let n = A(P.value + t), r = n.getUTCDay();
72
78
  return {
73
79
  n: n.getUTCDate(),
74
80
  weekend: r === 0 || r === 6
75
81
  };
76
82
  })), V = (e) => {
77
- let t = M(e), n = Math.max(t.s, N.value), r = Math.min(t.e, P.value);
83
+ let t = N(e), n = Math.max(t.s, P.value), r = Math.min(t.e, F.value);
78
84
  return {
79
- left: `${(n - N.value) * C.dayWidth}px`,
85
+ left: `${(n - P.value) * C.dayWidth}px`,
80
86
  width: `${Math.max(1, r - n + 1) * C.dayWidth}px`
81
87
  };
82
88
  }, H = n(() => {
83
- let t = O(e());
84
- return t >= N.value && t <= P.value ? (t - N.value + .5) * C.dayWidth : null;
85
- }), U = (e) => Math.min(100, Math.max(0, e.progress ?? 0)), oe = (e) => {
86
- let t = M(e), n = (e.after ?? []).map((e) => w.value.find((t) => t.id === e)?.label).filter(Boolean);
87
- return `${e.label}: ${z.value.format(k(t.s))} to ${z.value.format(k(t.e))}` + (e.progress == null ? "" : `, ${U(e)}% done`) + (n.length ? `, after ${n.join(" and ")}` : "");
89
+ let t = k(e());
90
+ return t >= P.value && t <= F.value ? (t - P.value + .5) * C.dayWidth : null;
91
+ }), U = (e) => Math.min(100, Math.max(0, e.progress ?? 0)), se = (e) => {
92
+ let t = N(e), n = (e.after ?? []).map((e) => T.value.find((t) => t.id === e)?.label).filter(Boolean);
93
+ return w.value.span(e.label, z.value.format(A(t.s)), z.value.format(A(t.e))) + (e.progress == null ? "" : `, ${w.value.done(U(e))}`) + (n.length ? `, ${w.value.after(n)}` : "");
88
94
  }, W = n(() => {
89
95
  let e = [], t = C.rowHeight;
90
- return w.value.forEach((n, r) => {
96
+ return T.value.forEach((n, r) => {
91
97
  for (let i of n.after ?? []) {
92
- let a = w.value.findIndex((e) => e.id === i);
98
+ let a = T.value.findIndex((e) => e.id === i);
93
99
  if (a < 0) continue;
94
- let o = V(w.value[a]), s = V(n), c = parseFloat(o.left) + parseFloat(o.width), l = parseFloat(s.left), u = a * t + t / 2, d = r * t + t / 2, f = u + (d > u ? t / 2 : -t / 2);
100
+ let o = V(T.value[a]), s = V(n), c = parseFloat(o.left) + parseFloat(o.width), l = parseFloat(s.left), u = a * t + t / 2, d = r * t + t / 2, f = u + (d > u ? t / 2 : -t / 2);
95
101
  e.push(l >= c + 12 ? `M${c} ${u}H${c + 6}V${d}H${l - 1}` : `M${c} ${u}H${c + 6}V${f}H${l - 8}V${d}H${l - 1}`);
96
102
  }
97
103
  }), e;
98
104
  }), G = d(""), K = !1;
99
105
  function q(e, t, n) {
100
- C.editable && !n.button && (n.stopPropagation(), n.currentTarget.setPointerCapture?.(n.pointerId), j.value = {
106
+ C.editable && !n.button && (n.stopPropagation(), n.currentTarget.setPointerCapture?.(n.pointerId), M.value = {
101
107
  id: e.id,
102
108
  mode: t,
103
109
  x0: n.clientX,
104
- s: O(e.start),
105
- e: O(e.end),
110
+ s: k(e.start),
111
+ e: k(e.end),
106
112
  delta: 0
107
113
  });
108
114
  }
109
115
  function J(e) {
110
- let t = j.value;
116
+ let t = M.value;
111
117
  t && (t.delta = Math.round((e.clientX - t.x0) / C.dayWidth));
112
118
  }
113
119
  function Y() {
114
- let e = j.value;
115
- if (!e || (j.value = null, K = e.delta !== 0, e.delta === 0)) return;
116
- let t = w.value.find((t) => t.id === e.id), n = e.mode === "move" ? {
120
+ let e = M.value;
121
+ if (!e || (M.value = null, K = e.delta !== 0, e.delta === 0)) return;
122
+ let t = T.value.find((t) => t.id === e.id), n = e.mode === "move" ? {
117
123
  s: e.s + e.delta,
118
124
  e: e.e + e.delta
119
125
  } : e.mode === "start" ? {
@@ -127,33 +133,33 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
127
133
  }
128
134
  function X(e, t, n) {
129
135
  let r = {
130
- start: A(t),
131
- end: A(n)
136
+ start: j(t),
137
+ end: j(n)
132
138
  };
133
- w.value = w.value.map((t) => t.id === e.id ? {
139
+ T.value = T.value.map((t) => t.id === e.id ? {
134
140
  ...t,
135
141
  ...r
136
- } : t), E("change", {
142
+ } : t), D("change", {
137
143
  ...e,
138
144
  ...r
139
- }, r), G.value = `${e.label}: ${z.value.format(k(t))} to ${z.value.format(k(n))}`;
145
+ }, r), G.value = w.value.span(e.label, z.value.format(A(t)), z.value.format(A(n)));
140
146
  }
141
147
  let Z = d(), Q = d(0);
142
- function se(e, t) {
143
- let n = t.key === "ArrowDown" ? e + 1 : t.key === "ArrowUp" ? e - 1 : t.key === "Home" ? 0 : t.key === "End" ? w.value.length - 1 : null;
148
+ function ce(e, t) {
149
+ let n = t.key === "ArrowDown" ? e + 1 : t.key === "ArrowUp" ? e - 1 : t.key === "Home" ? 0 : t.key === "End" ? T.value.length - 1 : null;
144
150
  if (n != null) {
145
151
  t.preventDefault();
146
- let e = Math.min(w.value.length - 1, Math.max(0, n));
152
+ let e = Math.min(T.value.length - 1, Math.max(0, n));
147
153
  Q.value = e, Z.value?.querySelectorAll(".bless-gantt__bar")[e]?.focus();
148
154
  } else if (C.editable && t.altKey && (t.key === "ArrowLeft" || t.key === "ArrowRight")) {
149
155
  t.preventDefault();
150
- let n = w.value[e], r = t.key === "ArrowRight" ? 1 : -1;
151
- t.shiftKey ? X(n, O(n.start), Math.max(O(n.start), O(n.end) + r)) : X(n, O(n.start) + r, O(n.end) + r);
152
- } else (t.key === "Enter" || t.key === " ") && (t.preventDefault(), $(w.value[e]));
156
+ let n = T.value[e], r = t.key === "ArrowRight" ? 1 : -1;
157
+ t.shiftKey ? X(n, k(n.start), Math.max(k(n.start), k(n.end) + r)) : X(n, k(n.start) + r, k(n.end) + r);
158
+ } else (t.key === "Enter" || t.key === " ") && (t.preventDefault(), $(T.value[e]));
153
159
  }
154
160
  function $(e) {
155
161
  if (K) return void (K = !1);
156
- T.value = T.value === e.id ? null : e.id, E("select", e);
162
+ E.value = E.value === e.id ? null : e.id, D("select", e);
157
163
  }
158
164
  return (e, n) => (u(), i("div", {
159
165
  ref_key: "root",
@@ -161,35 +167,35 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
161
167
  class: "bless-gantt",
162
168
  role: "group",
163
169
  "aria-label": o.label
164
- }, [a("div", g, [a("div", {
170
+ }, [a("div", h, [a("div", {
165
171
  class: "bless-gantt__body",
166
172
  style: l({ "--bless-gantt-label": `${o.labelWidth}px` })
167
- }, [a("div", ee, [n[0] ||= a("div", {
173
+ }, [a("div", g, [n[0] ||= a("div", {
168
174
  class: "bless-gantt__corner",
169
175
  style: { height: "56px" }
170
- }, null, -1), (u(!0), i(t, null, f(w.value, (e) => (u(), i("div", {
176
+ }, null, -1), (u(!0), i(t, null, f(T.value, (e) => (u(), i("div", {
171
177
  key: e.id,
172
178
  class: "bless-gantt__label",
173
179
  style: l({ height: `${o.rowHeight}px` }),
174
180
  title: e.label
175
- }, p(e.label), 13, te))), 128))]), a("div", {
181
+ }, p(e.label), 13, _))), 128))]), a("div", {
176
182
  class: "bless-gantt__plot",
177
- style: l({ width: `${I.value}px` })
178
- }, [a("div", _, [a("div", ne, [(u(!0), i(t, null, f(ae.value, (e) => (u(), i("span", {
183
+ style: l({ width: `${L.value}px` })
184
+ }, [a("div", te, [a("div", v, [(u(!0), i(t, null, f(oe.value, (e) => (u(), i("span", {
179
185
  key: e.left,
180
186
  class: "bless-gantt__month",
181
187
  style: l({
182
188
  left: `${e.left}px`,
183
189
  width: `${e.width}px`
184
190
  })
185
- }, p(e.text), 5))), 128))]), B.value.length ? (u(), i("div", v, [(u(!0), i(t, null, f(B.value, (e, t) => (u(), i("span", {
191
+ }, p(e.text), 5))), 128))]), B.value.length ? (u(), i("div", y, [(u(!0), i(t, null, f(B.value, (e, t) => (u(), i("span", {
186
192
  key: t,
187
193
  class: c(["bless-gantt__day", { "bless-gantt__day--weekend": e.weekend }]),
188
194
  style: l({ width: `${o.dayWidth}px` })
189
195
  }, p(e.n), 7))), 128))])) : r("", !0)]), a("div", {
190
196
  class: "bless-gantt__rows",
191
197
  style: l({
192
- height: `${w.value.length * o.rowHeight}px`,
198
+ height: `${T.value.length * o.rowHeight}px`,
193
199
  backgroundSize: `${o.dayWidth}px 100%`
194
200
  })
195
201
  }, [
@@ -202,8 +208,8 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
202
208
  W.value.length ? (u(), i("svg", {
203
209
  key: 1,
204
210
  class: "bless-gantt__arrows",
205
- width: I.value,
206
- height: w.value.length * o.rowHeight,
211
+ width: L.value,
212
+ height: T.value.length * o.rowHeight,
207
213
  "aria-hidden": "true"
208
214
  }, [n[1] ||= a("defs", null, [a("marker", {
209
215
  id: "bless-gantt-head",
@@ -220,14 +226,14 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
220
226
  key: t,
221
227
  d: e,
222
228
  "marker-end": "url(#bless-gantt-head)"
223
- }, null, 8, y))), 128))], 8, re)) : r("", !0),
224
- (u(!0), i(t, null, f(w.value, (e, n) => (u(), i("button", {
229
+ }, null, 8, x))), 128))], 8, b)) : r("", !0),
230
+ (u(!0), i(t, null, f(T.value, (e, n) => (u(), i("button", {
225
231
  key: e.id,
226
232
  type: "button",
227
233
  class: c(["bless-gantt__bar", {
228
- "bless-gantt__bar--on": T.value === e.id,
234
+ "bless-gantt__bar--on": E.value === e.id,
229
235
  "bless-gantt__bar--edit": o.editable,
230
- "bless-gantt__bar--drag": j.value?.id === e.id
236
+ "bless-gantt__bar--drag": M.value?.id === e.id
231
237
  }]),
232
238
  style: l({
233
239
  ...V(e),
@@ -235,11 +241,11 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
235
241
  height: `${o.rowHeight - 12}px`
236
242
  }),
237
243
  tabindex: n === Q.value ? 0 : -1,
238
- "aria-label": oe(e),
239
- "aria-pressed": T.value === e.id,
244
+ "aria-label": se(e),
245
+ "aria-pressed": E.value === e.id,
240
246
  onClick: (t) => (Q.value = n, $(e)),
241
247
  onFocus: (e) => Q.value = n,
242
- onKeydown: (e) => se(n, e),
248
+ onKeydown: (e) => ce(n, e),
243
249
  onPointerdown: (t) => q(e, "move", t),
244
250
  onPointermove: J,
245
251
  onPointerup: Y,
@@ -251,19 +257,19 @@ var h = ["aria-label"], g = { class: "bless-gantt__scroll" }, ee = { class: "ble
251
257
  onPointermove: J,
252
258
  onPointerup: Y,
253
259
  onPointercancel: Y
254
- }, null, 40, x), a("span", {
260
+ }, null, 40, S), a("span", {
255
261
  class: "bless-gantt__grip bless-gantt__grip--end",
256
262
  "aria-hidden": "true",
257
263
  onPointerdown: (t) => q(e, "end", t),
258
264
  onPointermove: J,
259
265
  onPointerup: Y,
260
266
  onPointercancel: Y
261
- }, null, 40, ie)], 64)) : r("", !0), e.progress == null ? r("", !0) : (u(), i("span", {
267
+ }, null, 40, re)], 64)) : r("", !0), e.progress == null ? r("", !0) : (u(), i("span", {
262
268
  key: 1,
263
269
  class: "bless-gantt__done",
264
270
  style: l({ width: `${U(e)}%` })
265
- }, null, 4))], 46, b))), 128))
266
- ], 4)], 4)], 4)]), a("span", S, p(G.value), 1)], 8, h));
271
+ }, null, 4))], 46, ne))), 128))
272
+ ], 4)], 4)], 4)]), a("span", ie, p(G.value), 1)], 8, ee));
267
273
  }
268
274
  });
269
275
  //#endregion
@@ -0,0 +1 @@
1
+ .bless-canvas{box-sizing:border-box;background:var(--bless-color-surface);border:var(--bless-border-width) solid var(--bless-color-border);cursor:grab;touch-action:none;-webkit-user-select:none;user-select:none;width:100%;min-height:240px;font-family:var(--bless-font-sans);font-size:var(--bless-text-sm);color:var(--bless-color-text);position:relative;overflow:hidden}.bless-canvas--grid{background-image:radial-gradient(circle, color-mix(in srgb, var(--bless-color-text-muted) 45%, transparent) 1px, transparent 1.5px)}.bless-canvas--pan{cursor:grabbing}.bless-canvas:focus-visible{outline:2px solid var(--bless-color-accent);outline-offset:2px}.bless-canvas__layer{transform-origin:0 0;width:0;height:0;position:absolute;top:0;left:0}.bless-canvas__controls{gap:var(--bless-space-1);cursor:default;display:flex;position:absolute;inset-block-end:var(--bless-space-2);inset-inline-end:var(--bless-space-2)}.bless-canvas__live{clip-path:inset(50%);width:1px;height:1px;position:absolute;overflow:hidden}
@@ -0,0 +1,6 @@
1
+ import "./BlessInfiniteCanvas.css";
2
+ import e, { blessCanvasKey as t } from "./BlessInfiniteCanvas.vue_vue_type_script_setup_true_lang.js";
3
+ //#region src/components/BlessInfiniteCanvas.vue
4
+ var n = e;
5
+ //#endregion
6
+ export { t as blessCanvasKey, n as default };
@@ -0,0 +1,91 @@
1
+ import { InjectionKey, Ref } from 'vue';
2
+ import { CanvasView } from '../composables/canvasView';
3
+ export type { CanvasView } from '../composables/canvasView';
4
+ /** what a canvas hands to the things placed on it */
5
+ export interface BlessCanvasContext {
6
+ view: Ref<CanvasView>;
7
+ /** a pointer position in the page -> a point in the canvas' own (world) coordinates */
8
+ toWorld: (clientX: number, clientY: number) => {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ }
13
+ export declare const blessCanvasKey: InjectionKey<BlessCanvasContext>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
16
+ declare const __VLS_export: __VLS_WithSlots<import('vue').DefineComponent<{
17
+ minZoom?: number;
18
+ maxZoom?: number;
19
+ /** draw a dot grid that moves and scales with the view */
20
+ grid?: boolean;
21
+ /** the + / − / fit buttons in the corner */
22
+ controls?: boolean;
23
+ /** turn the plain mouse wheel into zoom (otherwise it pans, and Ctrl+wheel or a pinch zooms) */
24
+ wheelZoom?: boolean;
25
+ label?: string;
26
+ labels?: Partial<{
27
+ zoomIn: string;
28
+ zoomOut: string;
29
+ reset: string;
30
+ zoom: (percent: number) => string;
31
+ hint: string;
32
+ }>;
33
+ } & {
34
+ view?: CanvasView;
35
+ }, {
36
+ zoomBy: (factor: number, at?: {
37
+ x: number;
38
+ y: number;
39
+ }) => void;
40
+ reset: () => void;
41
+ fit: (rect: {
42
+ x: number;
43
+ y: number;
44
+ width: number;
45
+ height: number;
46
+ }, pad?: number) => void;
47
+ centerOn: (x: number, y: number) => void;
48
+ toWorld: (cx: number, cy: number) => {
49
+ x: number;
50
+ y: number;
51
+ };
52
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
53
+ "update:view": (value: CanvasView) => any;
54
+ }, string, import('vue').PublicProps, Readonly<{
55
+ minZoom?: number;
56
+ maxZoom?: number;
57
+ /** draw a dot grid that moves and scales with the view */
58
+ grid?: boolean;
59
+ /** the + / − / fit buttons in the corner */
60
+ controls?: boolean;
61
+ /** turn the plain mouse wheel into zoom (otherwise it pans, and Ctrl+wheel or a pinch zooms) */
62
+ wheelZoom?: boolean;
63
+ label?: string;
64
+ labels?: Partial<{
65
+ zoomIn: string;
66
+ zoomOut: string;
67
+ reset: string;
68
+ zoom: (percent: number) => string;
69
+ hint: string;
70
+ }>;
71
+ } & {
72
+ view?: CanvasView;
73
+ }> & Readonly<{
74
+ "onUpdate:view"?: ((value: CanvasView) => any) | undefined;
75
+ }>, {
76
+ label: string;
77
+ grid: boolean;
78
+ controls: boolean;
79
+ minZoom: number;
80
+ maxZoom: number;
81
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, {
82
+ default?: (props: {
83
+ view: CanvasView;
84
+ zoom: number;
85
+ }) => any;
86
+ }>;
87
+ type __VLS_WithSlots<T, S> = T & {
88
+ new (): {
89
+ $slots: S;
90
+ };
91
+ };