@code0-tech/pictor 0.0.0-mvp.32 → 0.0.0-mvp.33

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.
@@ -1,21 +1,21 @@
1
1
  import { jsxs as W, jsx as g } from "react/jsx-runtime";
2
- import l, { useRef as S, useState as j, useMemo as D, useEffect as I, useLayoutEffect as Ze } from "react";
2
+ import l, { useRef as C, useState as j, useMemo as D, useEffect as I, useLayoutEffect as _e } from "react";
3
3
  import "../../utils/contextStore.js";
4
- import { mergeCode0Props as he } from "../../utils/utils.js";
4
+ import { mergeCode0Props as me } from "../../utils/utils.js";
5
5
  import '../../assets/components/form/Input.style.css';/* empty css */
6
- import { InputLabel as _e } from "./InputLabel.js";
7
- import { InputDescription as et } from "./InputDescription.js";
8
- import { InputMessage as tt } from "./InputMessage.js";
9
- import { Menu as nt, MenuTrigger as rt, MenuPortal as ot } from "../menu/Menu.js";
10
- import { InputSuggestionMenuContent as st, InputSuggestionMenuContentItems as at } from "./InputSuggestion.js";
11
- import { buildDefaultSyntax as ut } from "./Input.syntax.hook.js";
12
- import { getSelectionMetrics as it, setElementKey as lt, setSelectionRangeSafe as ct } from "./Input.utils.js";
13
- import { Card as ft } from "../card/Card.js";
14
- import { useContentEditableController as dt, setSelectionOffsetsInValue as pt } from "./InputContentEditable.hook.js";
6
+ import { InputLabel as et } from "./InputLabel.js";
7
+ import { InputDescription as tt } from "./InputDescription.js";
8
+ import { InputMessage as nt } from "./InputMessage.js";
9
+ import { Menu as rt, MenuTrigger as ot, MenuPortal as st } from "../menu/Menu.js";
10
+ import { InputSuggestionMenuContent as at, InputSuggestionMenuContentItems as ut } from "./InputSuggestion.js";
11
+ import { buildDefaultSyntax as it } from "./Input.syntax.hook.js";
12
+ import { getSelectionMetrics as lt, setElementKey as ct, setSelectionRangeSafe as ft } from "./Input.utils.js";
13
+ import { Card as dt } from "../card/Card.js";
14
+ import { useContentEditableController as pt, setSelectionOffsetsInValue as gt } from "./InputContentEditable.hook.js";
15
15
  const q = (u) => {
16
16
  const x = u ?? "";
17
17
  return typeof x == "string" ? x : String(x);
18
- }, se = (u) => {
18
+ }, ae = (u) => {
19
19
  if (u == null) return "";
20
20
  if (typeof u == "string") return u;
21
21
  try {
@@ -23,11 +23,11 @@ const q = (u) => {
23
23
  } catch {
24
24
  return String(u ?? "");
25
25
  }
26
- }, gt = (u) => {
26
+ }, ht = (u) => {
27
27
  if (u && typeof u == "object") {
28
28
  const {
29
29
  children: x,
30
- __contentHtml: J,
30
+ __contentHtml: Q,
31
31
  ...U
32
32
  } = u;
33
33
  return U;
@@ -35,114 +35,115 @@ const q = (u) => {
35
35
  return {
36
36
  value: u
37
37
  };
38
- }, Ke = (u) => {
38
+ }, Ae = (u) => {
39
39
  if (!u) return null;
40
- const x = u.value ?? "", J = u.selectionStart ?? x.length, T = x.slice(0, J).match(/\S+$/);
40
+ const x = u.value ?? "", Q = u.selectionStart ?? x.length, T = x.slice(0, Q).match(/\S+$/);
41
41
  if (!T || T.index === void 0) return null;
42
- const C = T[0], H = T.index, Q = H + C.length;
42
+ const b = T[0], H = T.index, G = H + b.length;
43
43
  return {
44
- token: C,
44
+ token: b,
45
45
  start: H,
46
- end: Q
46
+ end: G
47
47
  };
48
- }, ht = l.forwardRef((u, x) => {
48
+ }, mt = l.forwardRef((u, x) => {
49
49
  const {
50
- wrapperComponent: J = {},
50
+ wrapperComponent: Q = {},
51
51
  title: U,
52
52
  description: T,
53
- disabled: C = !1,
53
+ disabled: b = !1,
54
54
  left: H,
55
- right: Q,
56
- leftType: Ae = "icon",
57
- rightType: Ne = "action",
58
- formValidation: L = {
55
+ right: G,
56
+ leftType: Ne = "icon",
57
+ rightType: ze = "action",
58
+ formValidation: P = {
59
59
  valid: !0,
60
60
  notValidMessage: null,
61
61
  setValue: null
62
62
  },
63
63
  suggestions: f,
64
- suggestionsHeader: me,
65
- suggestionsFooter: ye,
66
- onSuggestionSelect: Se,
67
- disableOnValue: Ce = () => !1,
68
- transformSyntax: G,
69
- validationUsesSyntax: ae = !1,
70
- filterSuggestionsByLastToken: v = !1,
71
- enforceUniqueSuggestions: ve = !1,
72
- onLastTokenChange: be,
73
- suggestionsEmptyState: ke,
74
- ...ze
64
+ suggestionsHeader: ye,
65
+ suggestionsFooter: Se,
66
+ onSuggestionSelect: Ce,
67
+ disableOnValue: be = () => !1,
68
+ transformSyntax: X,
69
+ validationUsesSyntax: ue = !1,
70
+ filterSuggestionsByLastToken: k = !1,
71
+ enforceUniqueSuggestions: ke = !1,
72
+ onLastTokenChange: ve,
73
+ suggestionsEmptyState: xe,
74
+ ...We
75
75
  } = u, {
76
- onFocus: xe,
77
- onBlur: X,
78
- onKeyDown: Y,
79
- onKeyDownCapture: ue,
80
- onChange: P,
81
- onInput: M,
82
- ...b
83
- } = ze, Z = S(null), y = S(null), $ = S(null), F = S(null), ie = S(null), w = S(!1), le = S(!1), We = S(0), we = S(null), ce = b.value ?? u.initialValue ?? u.defaultValue, [Ee, je] = j(!1), B = S(!1), i = l.useCallback((e) => {
84
- B.current = e, je(e);
85
- }, []), [h, Ve] = j(ce), [De, Ie] = j([]), [K, fe] = j([]), [Te, qe] = j(null), [A, Ue] = j(null), s = !!G, R = D(() => Ce(h), [Ce, h]), k = D(() => s ? $ : y, [s]);
86
- l.useImperativeHandle(x, () => k.current ?? null);
87
- const He = D(() => ({
88
- ...b,
89
- onChange: P,
90
- onInput: M
91
- }), [b, P, M]), Je = D(() => {
76
+ onFocus: we,
77
+ onBlur: Y,
78
+ onKeyDown: Z,
79
+ onKeyDownCapture: ie,
80
+ onChange: R,
81
+ onInput: O,
82
+ ...h
83
+ } = We, _ = C(null), S = C(null), $ = C(null), F = C(null), le = C(null), w = C(!1), ce = C(!1), je = C(0), Ve = C(null), fe = h.value ?? u.initialValue ?? u.defaultValue, [Ee, qe] = j(!1), B = C(!1), i = l.useCallback((e) => {
84
+ B.current = e, qe(e);
85
+ }, []), [m, de] = j(fe), [De, Ie] = j([]), [K, pe] = j([]), [Te, Ue] = j(null), [A, He] = j(null), s = !!X, L = D(() => be(m), [be, m]), v = D(() => s ? $ : S, [s]);
86
+ l.useImperativeHandle(x, () => v.current ?? null);
87
+ const Je = D(() => ({
88
+ ...h
89
+ }), [h]), Qe = D(() => {
92
90
  const {
93
91
  value: e,
94
92
  defaultValue: t,
95
93
  ...n
96
- } = b;
97
- return he("input__control", n);
98
- }, [b]), _ = l.useCallback(() => {
99
- const e = k.current;
100
- !e || C || R || e.focus({
94
+ } = h;
95
+ return me("input__control", n);
96
+ }, [h]), ee = l.useCallback(() => {
97
+ const e = v.current;
98
+ !e || b || L || e.focus({
101
99
  preventScroll: !0
102
100
  });
103
- }, [k, C, R]), N = l.useCallback(() => {
101
+ }, [v, b, L]), N = l.useCallback(() => {
104
102
  f && i(!0);
105
- }, [f, i]), de = l.useCallback((e) => {
106
- v && (qe(e), e && i(!0), be?.(e));
107
- }, [v, be, i]), pe = l.useCallback((e, t) => {
108
- if (!L?.setValue) return;
109
- const n = b.type !== "checkbox" ? q(e) : e, o = ae ? t : n;
110
- Object.is(we.current, o) || (we.current = o, L.setValue(o));
111
- }, [L?.setValue, b.type, ae]), p = dt({
103
+ }, [f, i]), ge = l.useCallback((e) => {
104
+ k && (Ue(e), e && i(!0), ve?.(e));
105
+ }, [k, ve, i]), J = l.useCallback((e, t) => {
106
+ if (!P?.setValue) return;
107
+ const n = h.type !== "checkbox" ? q(e) : e, o = ue ? t : n;
108
+ Object.is(Ve.current, o) || (Ve.current = o, P.setValue(o));
109
+ }, [P?.setValue, h.type, ue]), Pe = l.useCallback((e) => {
110
+ const t = e.currentTarget, n = h.type === "checkbox" ? t.checked : t.value;
111
+ de(n), J(n, null);
112
+ }, [h.type, J]), p = pt({
112
113
  editorRef: $,
113
- transformSyntax: G,
114
- filterSuggestionsByLastToken: v,
115
- onLastTokenChange: de,
114
+ transformSyntax: X,
115
+ filterSuggestionsByLastToken: k,
116
+ onLastTokenChange: ge,
116
117
  onStateChange: ({
117
118
  value: e,
118
119
  tokens: t,
119
120
  segments: n
120
121
  }) => {
121
- Ve(e), fe(t), Ue(n ?? null), pe(e, n ?? null);
122
+ de(e), pe(t), He(n ?? null), J(e, n ?? null);
122
123
  }
123
- }), Le = S(!1);
124
+ }), Le = C(!1);
124
125
  I(() => {
125
- if (!s || !G || Le.current) return;
126
- const e = q(ce);
126
+ if (!s || !X || Le.current) return;
127
+ const e = q(fe);
127
128
  p.initializeFromExternalValue(e), Le.current = !0;
128
- }, [s, G, ce, ae, p]), I(() => {
129
- s || b.value !== void 0 && Ve(b.value);
130
- }, [b.value, s]), I(() => {
131
- pe(h, A);
132
- }, [pe, A, h]), I(() => {
129
+ }, [s, X, fe, ue, p]), I(() => {
130
+ s || h.value !== void 0 && de(h.value);
131
+ }, [h.value, s]), I(() => {
132
+ J(m, A);
133
+ }, [J, A, m]), I(() => {
133
134
  if (!f) return;
134
135
  const e = (t) => {
135
- const n = t.target, o = !!$.current?.contains(n), a = !!y.current?.contains(n), r = !!ie.current?.contains(n), m = !!Z.current?.contains(n), c = o || a || r || m;
136
+ const n = t.target, o = !!$.current?.contains(n), a = !!S.current?.contains(n), r = !!le.current?.contains(n), y = !!_.current?.contains(n), c = o || a || r || y;
136
137
  w.current = c, !c && B.current && i(!1);
137
138
  };
138
139
  return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
139
140
  }, [f, i]), I(() => {
140
- const e = Z.current;
141
+ const e = _.current;
141
142
  if (!e) return;
142
143
  const t = () => N();
143
144
  return e.addEventListener("focusin", t), () => e.removeEventListener("focusin", t);
144
145
  }, [N]);
145
- const Pe = l.useCallback((e, t, n) => {
146
+ const Me = l.useCallback((e, t, n) => {
146
147
  if (e.length === 0) return t <= n.length ? t : null;
147
148
  let o = n.indexOf(e);
148
149
  if (o === -1) return null;
@@ -150,10 +151,10 @@ const q = (u) => {
150
151
  for (; a !== -1; )
151
152
  Math.abs(a - t) < Math.abs(o - t) && (o = a), a = n.indexOf(e, a + 1);
152
153
  return o;
153
- }, []), ee = l.useCallback((e, t) => {
154
+ }, []), te = l.useCallback((e, t) => {
154
155
  const n = [];
155
156
  return e.forEach((o) => {
156
- const a = Pe(o.text, o.start, t);
157
+ const a = Me(o.text, o.start, t);
157
158
  if (a === null) return;
158
159
  const r = a + o.text.length;
159
160
  t.slice(a, r) === o.text && n.push({
@@ -162,81 +163,81 @@ const q = (u) => {
162
163
  end: r
163
164
  });
164
165
  }), n;
165
- }, [Pe]);
166
+ }, [Me]);
166
167
  I(() => {
167
168
  if (s) return;
168
- const e = q(y.current?.value ?? h);
169
+ const e = q(S.current?.value ?? m);
169
170
  Ie((t) => {
170
- const n = ee(t, e);
171
- return fe(n.map((o) => o.suggestion)), n;
171
+ const n = te(t, e);
172
+ return pe(n.map((o) => o.suggestion)), n;
172
173
  });
173
- }, [s, ee, h]), I(() => {
174
- if (!v || s) return;
175
- const e = y.current;
174
+ }, [s, te, m]), I(() => {
175
+ if (!k || s) return;
176
+ const e = S.current;
176
177
  if (!e) return;
177
- const t = () => de(Ke(e)?.token ?? null);
178
+ const t = () => ge(Ae(e)?.token ?? null);
178
179
  return e.addEventListener("input", t), e.addEventListener("keyup", t), e.addEventListener("mouseup", t), t(), () => {
179
180
  e.removeEventListener("input", t), e.removeEventListener("keyup", t), e.removeEventListener("mouseup", t);
180
181
  };
181
- }, [v, s, de]);
182
+ }, [k, s, ge]);
182
183
  const z = D(() => {
183
- if (!v || !f) return f;
184
+ if (!k || !f) return f;
184
185
  const e = Te?.trim();
185
186
  return e?.length ? f.filter((t) => String(t?.value ?? "").toLowerCase().startsWith(e.toLowerCase())) : f;
186
- }, [v, Te, f]), te = D(() => {
187
- if (!ve || !z) return z;
187
+ }, [k, Te, f]), ne = D(() => {
188
+ if (!ke || !z) return z;
188
189
  if (s) {
189
- const t = new Set((K ?? []).map((n) => se(n?.value ?? n)));
190
- return z.filter((n) => !t.has(se(n?.value ?? n)));
190
+ const t = new Set((K ?? []).map((n) => ae(n?.value ?? n)));
191
+ return z.filter((n) => !t.has(ae(n?.value ?? n)));
191
192
  }
192
193
  const e = new Set(De.map((t) => t.suggestion));
193
194
  return z.filter((t) => !e.has(t));
194
- }, [De, K, ve, z, s]), Me = l.useCallback((e) => {
195
- if (!y.current) return;
196
- const t = typeof h == "object" ? JSON.stringify(e.value) : e.value, n = t == null ? "" : String(t), o = e.insertMode ?? "replace", a = y.current.value ?? "";
197
- let r = a, m = null, c = 0;
198
- const E = v ? Ke(y.current) : null;
199
- if (v && E)
200
- r = `${a.slice(0, E.start)}${n}${a.slice(E.end)}`, m = E.start + n.length, c = E.start;
195
+ }, [De, K, ke, z, s]), Re = l.useCallback((e) => {
196
+ if (!S.current) return;
197
+ const t = typeof m == "object" ? JSON.stringify(e.value) : e.value, n = t == null ? "" : String(t), o = e.insertMode ?? "replace", a = S.current.value ?? "";
198
+ let r = a, y = null, c = 0;
199
+ const V = k ? Ae(S.current) : null;
200
+ if (k && V)
201
+ r = `${a.slice(0, V.start)}${n}${a.slice(V.end)}`, y = V.start + n.length, c = V.start;
201
202
  else
202
203
  switch (o) {
203
204
  case "append":
204
- r = `${a}${n}`, m = r.length, c = a.length;
205
+ r = `${a}${n}`, y = r.length, c = a.length;
205
206
  break;
206
207
  case "prepend":
207
- r = `${n}${a}`, m = n.length, c = 0;
208
+ r = `${n}${a}`, y = n.length, c = 0;
208
209
  break;
209
210
  case "insert": {
210
211
  const {
211
212
  rawStart: d,
212
- rawEnd: O
213
- } = it(y.current);
214
- r = `${a.slice(0, d)}${n}${a.slice(O)}`, m = d + n.length, c = d;
213
+ rawEnd: M
214
+ } = lt(S.current);
215
+ r = `${a.slice(0, d)}${n}${a.slice(M)}`, y = d + n.length, c = d;
215
216
  break;
216
217
  }
217
218
  case "replace":
218
219
  default:
219
- r = n, m = n.length, c = 0;
220
+ r = n, y = n.length, c = 0;
220
221
  break;
221
222
  }
222
- lt(y.current, "value", r, "change"), Ie((d) => {
223
- const O = q(r), re = ee(d, O), V = n.length ? {
224
- id: We.current++,
223
+ ct(S.current, "value", r, "change"), Ie((d) => {
224
+ const M = q(r), oe = te(d, M), E = n.length ? {
225
+ id: je.current++,
225
226
  suggestion: e,
226
227
  text: n,
227
228
  start: c,
228
229
  end: c + n.length
229
- } : null, oe = V ? [...re, V] : re;
230
- return fe(oe.map((Ye) => Ye.suggestion)), oe;
231
- }), m !== null && requestAnimationFrame(() => {
232
- const d = y.current;
230
+ } : null, se = E ? [...oe, E] : oe;
231
+ return pe(se.map((Ze) => Ze.suggestion)), se;
232
+ }), y !== null && requestAnimationFrame(() => {
233
+ const d = S.current;
233
234
  d && (d.focus({
234
235
  preventScroll: !0
235
- }), ct(d, m, m));
236
+ }), ft(d, y, y));
236
237
  });
237
- }, [v, ee, h]), Re = l.useCallback((e) => {
238
- if (s ? p.applySuggestionValueSyntax(e) : Me(e), Se?.(e), s) {
239
- const t = k.current;
238
+ }, [k, te, m]), Oe = l.useCallback((e) => {
239
+ if (s ? p.applySuggestionValueSyntax(e) : Re(e), Ce?.(e), s) {
240
+ const t = v.current;
240
241
  requestAnimationFrame(() => {
241
242
  if (!t) return;
242
243
  const n = {
@@ -246,31 +247,31 @@ const q = (u) => {
246
247
  };
247
248
  t.dispatchEvent(new Event("input", {
248
249
  bubbles: !0
249
- })), M?.(n), P?.(n);
250
+ })), O?.(n), R?.(n);
250
251
  });
251
252
  }
252
253
  i(!1), w.current = !1, requestAnimationFrame(() => {
253
- _();
254
+ ee();
254
255
  });
255
- }, [k, Me, p, _, s, Se, i, P, M]), Oe = l.useCallback((e) => {
256
- N(), xe?.(e);
257
- }, [N, xe]), ne = l.useCallback((e) => {
258
- if (le.current) {
259
- le.current = !1, X?.(e);
256
+ }, [v, Re, p, ee, s, Ce, i, R, O]), $e = l.useCallback((e) => {
257
+ N(), we?.(e);
258
+ }, [N, we]), re = l.useCallback((e) => {
259
+ if (ce.current) {
260
+ ce.current = !1, Y?.(e);
260
261
  return;
261
262
  }
262
263
  if (w.current) {
263
- X?.(e);
264
+ Y?.(e);
264
265
  return;
265
266
  }
266
- i(!1), X?.(e);
267
- }, [X, i]), $e = l.useCallback((e) => {
267
+ i(!1), Y?.(e);
268
+ }, [Y, i]), Fe = l.useCallback((e) => {
268
269
  if (s) {
269
- p.handleKeyDownCapture(e), ue?.(e);
270
+ p.handleKeyDownCapture(e), ie?.(e);
270
271
  return;
271
272
  }
272
- (e.key === " " || e.code === "Space") && (e.stopPropagation(), e.nativeEvent?.stopImmediatePropagation?.()), ue?.(e);
273
- }, [p, s, ue]), Fe = l.useCallback((e) => {
273
+ (e.key === " " || e.code === "Space") && (e.stopPropagation(), e.nativeEvent?.stopImmediatePropagation?.()), ie?.(e);
274
+ }, [p, s, ie]), Be = l.useCallback((e) => {
274
275
  if (f) {
275
276
  if (e.key === "ArrowDown") {
276
277
  e.preventDefault(), e.stopPropagation(), B.current ? F.current?.highlightNextItem?.() : (i(!0), setTimeout(() => F.current?.focusFirstItem?.(), 0));
@@ -291,70 +292,70 @@ const q = (u) => {
291
292
  }
292
293
  if (s && p.handleKeyDown(e)) {
293
294
  if (e.key === "Backspace" || e.key === "Delete") {
294
- const n = k.current;
295
+ const n = v.current;
295
296
  if (n) {
296
297
  const o = {
297
298
  type: "change",
298
299
  target: n,
299
300
  currentTarget: n
300
301
  };
301
- M?.(o), P?.(o);
302
+ O?.(o), R?.(o);
302
303
  }
303
304
  }
304
- Y?.(e);
305
+ Z?.(e);
305
306
  return;
306
307
  }
307
308
  if (s && e.key === "Enter") {
308
- e.preventDefault(), Y?.(e);
309
+ e.preventDefault(), Z?.(e);
309
310
  return;
310
311
  }
311
- Y?.(e);
312
- }, [k, p, s, f, i, P, M, Y]), Be = D(() => {
312
+ Z?.(e);
313
+ }, [v, p, s, f, i, R, O, Z]), Ke = D(() => {
313
314
  if (!s) return null;
314
- const e = q(h), t = (A ?? []).filter(Boolean).filter((r) => r && (r.type === "text" || r.type === "block") && Number.isFinite(r.start) && Number.isFinite(r.end) && r.start <= r.end), n = t.length ? t : ut(e), o = (K ?? []).slice(), a = [];
315
- return n.forEach((r, m) => {
315
+ const e = q(m), t = (A ?? []).filter(Boolean).filter((r) => r && (r.type === "text" || r.type === "block") && Number.isFinite(r.start) && Number.isFinite(r.end) && r.start <= r.end), n = t.length ? t : it(e), o = (K ?? []).slice(), a = [];
316
+ return n.forEach((r, y) => {
316
317
  const c = r.value ?? e.slice(r.start, r.end);
317
318
  if (r.type === "text") {
318
- const V = typeof r.content == "string" ? r.content : typeof c == "string" ? c : e.slice(r.start, r.end);
319
- V?.length && a.push(V);
319
+ const E = typeof r.content == "string" ? r.content : typeof c == "string" ? c : e.slice(r.start, r.end);
320
+ E?.length && a.push(E);
320
321
  return;
321
322
  }
322
- const E = se(c);
323
+ const V = ae(c);
323
324
  let d;
324
325
  if (o.length) {
325
- const V = o[0], oe = se(V?.value ?? V);
326
- (E === "" || oe === E) && (d = V, o.shift());
326
+ const E = o[0], se = ae(E?.value ?? E);
327
+ (V === "" || se === V) && (d = E, o.shift());
327
328
  }
328
329
  d || (d = {
329
330
  value: c
330
331
  });
331
- const O = gt(d), re = r.content && typeof r.content != "string" || typeof r.content == "string" ? r.content : O?.label ?? O?.value ?? "";
332
+ const M = ht(d), oe = r.content && typeof r.content != "string" || typeof r.content == "string" ? r.content : M?.label ?? M?.value ?? "";
332
333
  a.push(/* @__PURE__ */ W(l.Fragment, { children: [
333
334
  "​",
334
- /* @__PURE__ */ g("span", { className: "input__token", contentEditable: !1, "aria-data": JSON.stringify(O), style: {
335
+ /* @__PURE__ */ g("span", { className: "input__token", contentEditable: !1, "aria-data": JSON.stringify(M), style: {
335
336
  display: "inline-flex",
336
337
  alignItems: "center",
337
338
  verticalAlign: "middle",
338
339
  userSelect: "text",
339
340
  WebkitUserSelect: "text"
340
- }, children: re }),
341
+ }, children: oe }),
341
342
  "​"
342
- ] }, `${m}-${E}`));
343
+ ] }, `${y}-${V}`));
343
344
  }), a;
344
- }, [K, s, A, h]);
345
- Ze(() => {
345
+ }, [K, s, A, m]);
346
+ _e(() => {
346
347
  if (!s) return;
347
348
  const e = $.current;
348
349
  if (!e) return;
349
350
  const t = p.takePendingSelection();
350
- t && pt(e, t.start, t.end);
351
- }, [p, s, Be]);
352
- const Qe = D(() => {
351
+ t && gt(e, t.start, t.end);
352
+ }, [p, s, Ke]);
353
+ const Ge = D(() => {
353
354
  if (!s) return "plain";
354
- const e = q(h), t = K?.length ?? 0, n = A?.length ?? 0;
355
+ const e = q(m), t = K?.length ?? 0, n = A?.length ?? 0;
355
356
  return `${e}-${t}-${n}`;
356
- }, [K, s, A, h]), ge = s ? /* @__PURE__ */ g("div", { ref: $, ...Je, contentEditable: !C && !R, suppressContentEditableWarning: !0, "aria-disabled": C || R, onInput: (e) => {
357
- p.updateEditorState($.current), f && (w.current = !0, le.current = !0, i(!0), requestAnimationFrame(() => {
357
+ }, [K, s, A, m]), he = s ? /* @__PURE__ */ g("div", { ref: $, ...Qe, contentEditable: !b && !L, suppressContentEditableWarning: !0, "aria-disabled": b || L, onInput: (e) => {
358
+ p.updateEditorState($.current), f && (w.current = !0, ce.current = !0, i(!0), requestAnimationFrame(() => {
358
359
  w.current = !1;
359
360
  }));
360
361
  const t = e.currentTarget, n = {
@@ -362,67 +363,71 @@ const q = (u) => {
362
363
  target: t,
363
364
  currentTarget: t
364
365
  };
365
- M?.(n), P?.(n);
366
+ O?.(n), R?.(n);
366
367
  }, onChange: (e) => {
367
368
  p.handleChange(e);
368
- }, onPaste: p.handlePaste, onFocus: Oe, onBlur: ne, onKeyDownCapture: $e, onKeyDown: Fe, spellCheck: !1, children: Be }, Qe) : /* @__PURE__ */ g("input", { ref: y, ...he("input__control", He), onFocus: Oe, onBlur: ne, onKeyDownCapture: $e, onKeyDown: Fe, spellCheck: !1, disabled: C || R }), Ge = l.useCallback((e) => {
369
- if (C || R) return;
369
+ }, onPaste: p.handlePaste, onFocus: $e, onBlur: re, onKeyDownCapture: Fe, onKeyDown: Be, spellCheck: !1, children: Ke }, Ge) : /* @__PURE__ */ g("input", { ref: S, ...me("input__control", Je), onFocus: $e, onBlur: re, onKeyDownCapture: Fe, onKeyDown: Be, onInput: (e) => {
370
+ Pe(e), O?.(e);
371
+ }, onChange: (e) => {
372
+ Pe(e), R?.(e);
373
+ }, spellCheck: !1, disabled: b || L }), Xe = l.useCallback((e) => {
374
+ if (b || L) return;
370
375
  const t = e.target;
371
- ie.current?.contains(t) || (w.current = !0, _(), N());
372
- }, [C, R, _, N]);
376
+ le.current?.contains(t) || (w.current = !0, ee(), N());
377
+ }, [b, L, ee, N]);
373
378
  I(() => {
374
- const e = Z.current;
379
+ const e = _.current;
375
380
  if (!e) return;
376
381
  const t = (n) => {
377
382
  const o = n.relatedTarget;
378
- o && e.contains(o) || ne(n);
383
+ o && e.contains(o) || re(n);
379
384
  };
380
385
  return e.addEventListener("focusout", t), () => e.removeEventListener("focusout", t);
381
- }, [ne]);
382
- const Xe = D(() => /* @__PURE__ */ W(nt, { open: Ee, modal: !1, onOpenChange: (e) => {
386
+ }, [re]);
387
+ const Ye = D(() => /* @__PURE__ */ W(rt, { open: Ee, modal: !1, onOpenChange: (e) => {
383
388
  !e && w.current || i(e);
384
389
  }, children: [
385
- /* @__PURE__ */ g(rt, { asChild: !0, children: /* @__PURE__ */ g("button", { type: "button", tabIndex: -1, "aria-hidden": !0, style: {
390
+ /* @__PURE__ */ g(ot, { asChild: !0, children: /* @__PURE__ */ g("button", { type: "button", tabIndex: -1, "aria-hidden": !0, style: {
386
391
  position: "absolute",
387
392
  inset: 0,
388
393
  opacity: 0,
389
394
  pointerEvents: "none"
390
395
  }, onMouseDown: (e) => e.preventDefault() }) }),
391
- ge,
392
- /* @__PURE__ */ g(ot, { children: /* @__PURE__ */ g("div", { ref: ie, onPointerDownCapture: () => {
396
+ he,
397
+ /* @__PURE__ */ g(st, { children: /* @__PURE__ */ g("div", { ref: le, onPointerDownCapture: () => {
393
398
  w.current = !0;
394
399
  }, onMouseDownCapture: (e) => {
395
400
  e.preventDefault(), w.current = !0;
396
- }, children: /* @__PURE__ */ W(st, { color: "secondary", inputRef: k, children: [
397
- me,
398
- /* @__PURE__ */ W(ft, { paddingSize: "xxs", mt: -0.35, mx: -0.35, style: {
401
+ }, children: /* @__PURE__ */ W(at, { color: "secondary", inputRef: v, children: [
402
+ ye,
403
+ /* @__PURE__ */ W(dt, { paddingSize: "xxs", mt: -0.35, mx: -0.35, style: {
399
404
  borderWidth: "2px"
400
405
  }, children: [
401
- te?.length === 0 && ke,
402
- !!te?.length && /* @__PURE__ */ g(
403
- at,
406
+ ne?.length === 0 && xe,
407
+ !!ne?.length && /* @__PURE__ */ g(
408
+ ut,
404
409
  {
405
410
  ref: F,
406
- inputRef: k,
407
- suggestions: te,
408
- onSuggestionSelect: Re
411
+ inputRef: v,
412
+ suggestions: ne,
413
+ onSuggestionSelect: Oe
409
414
  }
410
415
  )
411
416
  ] }),
412
- ye
417
+ Se
413
418
  ] }) }) })
414
- ] }), [Ee, ge, s, te, me, ye, ke, Re, k, i]);
419
+ ] }), [Ee, he, s, ne, ye, Se, xe, Oe, v, i]);
415
420
  return /* @__PURE__ */ W("div", { children: [
416
- U && /* @__PURE__ */ g(_e, { children: U }),
417
- T && /* @__PURE__ */ g(et, { children: T }),
418
- /* @__PURE__ */ W("div", { ref: Z, ...he(`input ${L?.valid ? "" : "input--not-valid"}`, J), onPointerDown: Ge, children: [
419
- H && /* @__PURE__ */ g("div", { className: `input__left input__left--${Ae}`, children: H }),
420
- f ? Xe : ge,
421
- Q && /* @__PURE__ */ g("div", { className: `input__right input__right--${Ne}`, children: Q })
421
+ U && /* @__PURE__ */ g(et, { children: U }),
422
+ T && /* @__PURE__ */ g(tt, { children: T }),
423
+ /* @__PURE__ */ W("div", { ref: _, ...me(`input ${P?.valid ? "" : "input--not-valid"}`, Q), onPointerDown: Xe, children: [
424
+ H && /* @__PURE__ */ g("div", { className: `input__left input__left--${Ne}`, children: H }),
425
+ f ? Ye : he,
426
+ G && /* @__PURE__ */ g("div", { className: `input__right input__right--${ze}`, children: G })
422
427
  ] }),
423
- !L?.valid && L?.notValidMessage && /* @__PURE__ */ g(tt, { children: L.notValidMessage })
428
+ !P?.valid && P?.notValidMessage && /* @__PURE__ */ g(nt, { children: P.notValidMessage })
424
429
  ] });
425
- }), Lt = ht;
430
+ }), Lt = mt;
426
431
  export {
427
432
  Lt as Input
428
433
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code0-tech/pictor",
3
- "version": "0.0.0-mvp.32",
3
+ "version": "0.0.0-mvp.33",
4
4
  "type": "module",
5
5
  "description": "A simple template for a custom React component library",
6
6
  "scripts": {