@janbox/storefront-builder 2.0.1 → 2.0.2

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 (36) hide show
  1. package/README.md +2 -2
  2. package/dist/anchor-target-CtXzdkBu.js +2918 -0
  3. package/dist/{color-picker-popover-B3AVFuei.js → color-picker-popover-XeaVfYS8.js} +104 -80
  4. package/dist/countdown-timer.node-Bh5fTSJ8.js +913 -0
  5. package/dist/date-picker-D9K6HWl-.js +157 -0
  6. package/dist/{dialog-header-DPLOS7TT.js → dialog-header-Bh3Dkw2q.js} +2440 -2122
  7. package/dist/dropzone-CF4CWXth.js +546 -0
  8. package/dist/editor/toolbars.js +171 -161
  9. package/dist/editor/ui/button-group/button-group.d.ts +1 -1
  10. package/dist/editor/ui/dialog/dialog-body/dialog-body.d.ts +1 -1
  11. package/dist/editor/ui/form-label/form-label.d.ts +1 -1
  12. package/dist/editor/ui/input/input.d.ts +1 -2
  13. package/dist/editor/ui/loading-overlay/loading-overlay.d.ts +1 -1
  14. package/dist/editor/ui/popover/popover-close.d.ts +1 -1
  15. package/dist/editor/ui/tabs/tab-content.d.ts +1 -1
  16. package/dist/editor/ui/tabs/tab-list.d.ts +2 -4
  17. package/dist/editor/ui/tabs/tab-panel.d.ts +1 -1
  18. package/dist/editor/ui/tabs/tab.d.ts +2 -5
  19. package/dist/editor/ui/tabs/tabs.d.ts +1 -1
  20. package/dist/editor/ui.js +82 -72
  21. package/dist/editor.js +822 -586
  22. package/dist/index-800HnUOi.js +4 -0
  23. package/dist/{index-CwrFnubn.js → index-CXyljfMv.js} +1729 -1584
  24. package/dist/index.js +287 -247
  25. package/dist/style.css +1 -1
  26. package/dist/templates.js +10 -12
  27. package/dist/theme/index.d.ts +293 -0
  28. package/dist/tooltip-CXOlTkGg.js +75 -0
  29. package/dist/utils/common.d.ts +0 -2
  30. package/package.json +1 -2
  31. package/dist/anchor-target-BlOvysAr.js +0 -2329
  32. package/dist/countdown-timer.node-OmDiT-pz.js +0 -825
  33. package/dist/date-picker-B4Rju7gG.js +0 -115
  34. package/dist/dropzone-Dbfed3jK.js +0 -490
  35. package/dist/index-BbiQ0n_-.js +0 -4
  36. package/dist/tooltip-KbIHELP2.js +0 -65
@@ -0,0 +1,546 @@
1
+ import { jsx as t, jsxs as R, Fragment as xe } from "@emotion/react/jsx-runtime";
2
+ import { Children as B, isValidElement as _, cloneElement as q, useRef as $, useEffect as Ce, useMemo as j, useCallback as X, Fragment as ke } from "react";
3
+ import { useControllableState as I } from "@janbox/storefront-ui/hooks";
4
+ import { t as u, l as J, k as K, W as P, P as ye, M as Ie, D as Se, E as We, F as Ne, G as Q, H as Ve } from "./dialog-header-Bh3Dkw2q.js";
5
+ import { ClassNames as Ee } from "@emotion/react";
6
+ import { useMergeRefs as G, useFloating as ee, autoUpdate as te, offset as ne, flip as oe, size as se, useClick as re, useHover as Re, safePolygon as Ae, useDismiss as ie, useRole as le, useInteractions as ae, useFloatingParentNodeId as Te, FloatingTree as Oe, FloatingPortal as Pe } from "@floating-ui/react";
7
+ import { isNumber as Me, isNil as M, merge as ze, isUndefined as ce, get as D } from "lodash-es";
8
+ import { useUpdateEffect as Fe } from "react-use";
9
+ import { FLOATING_Z_INDEX as L } from "@janbox/storefront-ui/theme";
10
+ import { useVirtualizer as De } from "@tanstack/react-virtual";
11
+ import { OverlayScrollbarsComponent as Le } from "overlayscrollbars-react";
12
+ import { useDropzone as Be } from "react-dropzone";
13
+ const lt = ({
14
+ children: e,
15
+ defaultValue: o,
16
+ value: s,
17
+ onSelectionChange: l,
18
+ ...a
19
+ }) => {
20
+ const [i, b] = I({
21
+ defaultValue: o ?? null,
22
+ value: s
23
+ }), c = B.toArray(e).filter(
24
+ (r) => _(r)
25
+ ), d = (r) => {
26
+ const w = r.currentTarget.value;
27
+ w !== i && (b(w), l?.(w, r));
28
+ };
29
+ return /* @__PURE__ */ t(Ee, { children: ({ cx: r, css: w }) => /* @__PURE__ */ t(
30
+ "div",
31
+ {
32
+ css: {
33
+ padding: 4,
34
+ display: "flex",
35
+ alignItems: "center",
36
+ gap: 8,
37
+ borderRadius: 8,
38
+ backgroundColor: u.palette.white["1s"]
39
+ },
40
+ ...a,
41
+ children: c.map(
42
+ (p) => q(p, {
43
+ ...p.props,
44
+ onClick(v) {
45
+ d(v), p.props.onClick?.(v);
46
+ },
47
+ className: r(
48
+ w([
49
+ {
50
+ color: u.palette.white["4s"]
51
+ },
52
+ p.props.value?.toString() === i && {
53
+ backgroundColor: u.palette.black["7s"],
54
+ color: u.palette.white["6s"]
55
+ }
56
+ ]),
57
+ p.props.className
58
+ )
59
+ })
60
+ )
61
+ }
62
+ ) });
63
+ }, Z = 10, at = ({
64
+ min: e = 0,
65
+ max: o = Number.MAX_SAFE_INTEGER,
66
+ fractionDigits: s = 0,
67
+ value: l,
68
+ defaultValue: a,
69
+ step: i = 0,
70
+ ref: b,
71
+ ...c
72
+ }) => {
73
+ const d = $(null), [r, w] = I({
74
+ value: l?.toString(),
75
+ defaultValue: a?.toString() ?? ""
76
+ }), p = parseFloat(r), v = G([b, d]), S = typeof s == "number" ? s : Z, W = (n) => {
77
+ if (n = n.replace(/e|E/g, ""), e >= 0 && (n = n.replace(/^-/, "")), s === 0)
78
+ n = n.replace(/\.\d+$/, "");
79
+ else {
80
+ const g = n.split(".");
81
+ if (g.length > 1) {
82
+ const h = g.at(1)?.slice(0, Math.min(S, Z));
83
+ n = `${g.at(0)}.${h}`;
84
+ }
85
+ }
86
+ return c.transform?.(n) ?? n;
87
+ }, N = (n) => {
88
+ c.mode === "onBlur" && n.target.valueAsNumber < e && (n.target.value = e.toString()), w(n.target.value), c.onChange?.(n);
89
+ }, V = (n) => {
90
+ (n.key === "e" || n.key === "E") && n.preventDefault(), c.onKeyDown?.(n);
91
+ }, y = (n) => {
92
+ if (!d.current) return;
93
+ Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")?.set?.call(d.current, n);
94
+ const h = new Event("input", { bubbles: !0 });
95
+ d.current.dispatchEvent(h);
96
+ }, C = (n) => {
97
+ const g = d.current;
98
+ if (M(g)) return;
99
+ const h = g.valueAsNumber, k = Math.min(isNaN(h) ? e + i : h + i, o);
100
+ h !== k && y(k.toString());
101
+ }, E = (n) => {
102
+ const g = d.current;
103
+ if (M(g)) return;
104
+ const h = g.valueAsNumber, k = Math.max(isNaN(h) ? e : h - i, e);
105
+ h !== k && y(k.toString());
106
+ };
107
+ return /* @__PURE__ */ t(
108
+ J,
109
+ {
110
+ ...c,
111
+ css: {
112
+ "::-webkit-outer-spin-button": {
113
+ margin: 0,
114
+ WebkitAppearance: "none"
115
+ },
116
+ "::-webkit-inner-spin-button": {
117
+ WebkitAppearance: "none",
118
+ margin: 0
119
+ }
120
+ },
121
+ prefix: c.prefix ?? (i > 0 ? /* @__PURE__ */ t(
122
+ K,
123
+ {
124
+ disabled: Me(l) && l <= e,
125
+ onClick: E,
126
+ "aria-disabled": isNaN(p) ? !1 : p >= o,
127
+ children: /* @__PURE__ */ t(P, { source: Ie })
128
+ }
129
+ ) : null),
130
+ suffix: c.suffix ?? (i > 0 ? /* @__PURE__ */ t(K, { onClick: C, "aria-disabled": isNaN(p) ? !1 : p <= e, children: /* @__PURE__ */ t(P, { source: ye }) }) : null),
131
+ type: "number",
132
+ value: r,
133
+ onChange: N,
134
+ transform: W,
135
+ ref: v,
136
+ onKeyDown: V
137
+ }
138
+ );
139
+ }, ct = ({ event: e = "click", reason: o, ref: s, ...l }) => {
140
+ const a = $(null), {
141
+ context: { onOpenChange: i }
142
+ } = Se(), b = G([s, a]);
143
+ return Ce(() => {
144
+ const c = a.current;
145
+ if (!c) return;
146
+ const d = function(r) {
147
+ i?.(!1, r, o);
148
+ };
149
+ return c.addEventListener(e, d), () => {
150
+ c.removeEventListener(e, d);
151
+ };
152
+ }, [e, i, o]), /* @__PURE__ */ t(
153
+ "div",
154
+ {
155
+ css: {
156
+ display: "contents"
157
+ },
158
+ ...l,
159
+ ref: b
160
+ }
161
+ );
162
+ }, Y = ({
163
+ open: e,
164
+ placement: o = "bottom",
165
+ onOpenChange: s,
166
+ dissmiss: l,
167
+ children: a,
168
+ reference: i,
169
+ trigger: b = "click",
170
+ offset: c = 4
171
+ }) => {
172
+ const [d, r] = I({
173
+ defaultValue: !1,
174
+ value: e
175
+ }), p = ee({
176
+ open: d,
177
+ onOpenChange: (n, g, h) => {
178
+ r(n), s?.(n, g, h);
179
+ },
180
+ placement: o,
181
+ middleware: [
182
+ ne(c),
183
+ oe(),
184
+ se({
185
+ apply({ elements: n }) {
186
+ const g = {
187
+ zIndex: `${L}`,
188
+ minWidth: `${n.reference.getBoundingClientRect().width}px`
189
+ };
190
+ Object.assign(n.floating.style, g);
191
+ }
192
+ })
193
+ ],
194
+ whileElementsMounted: te
195
+ }), { context: v, refs: S } = p, W = re(v, {
196
+ enabled: b === "click"
197
+ }), N = Re(v, {
198
+ enabled: b === "hover",
199
+ handleClose: Ae()
200
+ }), V = ie(
201
+ v,
202
+ ze(
203
+ {
204
+ ancestorScroll: !0
205
+ },
206
+ l
207
+ )
208
+ ), y = le(v), C = ae([W, V, y, N]), E = j(
209
+ () => ({
210
+ ...p,
211
+ ...C
212
+ }),
213
+ [p, C]
214
+ );
215
+ return Fe(() => {
216
+ ce(i) || (S.setReference?.(i), v.onOpenChange(!M(i)));
217
+ }, [i]), /* @__PURE__ */ t(We.Provider, { value: E, children: a });
218
+ }, dt = (e) => Te() ? /* @__PURE__ */ t(Y, { ...e }) : /* @__PURE__ */ t(Oe, { children: /* @__PURE__ */ t(Y, { ...e }) }), ut = ({ defaultIndex: e, activeIndex: o, children: s, onTabChange: l, ...a }) => {
219
+ const [i, b] = I({
220
+ defaultValue: e ?? 0,
221
+ value: o
222
+ }), c = (r) => {
223
+ b(r), l?.(r);
224
+ }, d = j(() => ({
225
+ activeIndex: i,
226
+ focusTab: c
227
+ }), [i]);
228
+ return /* @__PURE__ */ t(Ne.Provider, { value: d, children: /* @__PURE__ */ t("div", { css: { display: "flex", flexDirection: "column" }, ...a, children: s }) });
229
+ }, _e = ({ fill: e = !1, ...o }) => {
230
+ const { activeIndex: s, focusTab: l } = Q(), a = Number(D(o, "data-tab-index")), i = (b) => {
231
+ l(a), o.onClick?.(b);
232
+ };
233
+ return /* @__PURE__ */ t(
234
+ "li",
235
+ {
236
+ "aria-hidden": !0,
237
+ css: [
238
+ {
239
+ paddingInline: 12,
240
+ paddingBlock: 8,
241
+ borderTopLeftRadius: 8,
242
+ borderTopRightRadius: 8,
243
+ color: u.palette.white["5s"],
244
+ textAlign: "center",
245
+ cursor: "pointer"
246
+ },
247
+ s === a && {
248
+ color: u.palette.white["6s"],
249
+ backgroundColor: u.palette.black["7s"]
250
+ },
251
+ e && {
252
+ flex: 1
253
+ }
254
+ ],
255
+ ...o,
256
+ onClick: i
257
+ }
258
+ );
259
+ }, pt = ({ children: e, ...o }) => {
260
+ const s = B.toArray(e).filter(
261
+ (l) => _(l) && l.type === _e
262
+ );
263
+ return /* @__PURE__ */ t("ul", { css: [{ display: "flex", alignItems: "center" }], ...o, children: s.map(
264
+ (l, a) => q(l, {
265
+ "data-tab-index": a
266
+ })
267
+ ) });
268
+ }, $e = ({ ...e }) => /* @__PURE__ */ t("div", { ...e }), ft = ({ children: e, ...o }) => {
269
+ const { activeIndex: s } = Q(), l = B.toArray(e).filter((a) => _(a) && a.type === $e).find((a, i) => i === s);
270
+ return /* @__PURE__ */ t(
271
+ "div",
272
+ {
273
+ css: { position: "relative", borderTopWidth: 1, borderTopStyle: "solid", borderColor: u.palette.white["1s"] },
274
+ ...o,
275
+ children: l
276
+ }
277
+ );
278
+ }, je = ({ children: e, options: o, ...s }) => /* @__PURE__ */ t(
279
+ Le,
280
+ {
281
+ options: {
282
+ scrollbars: {
283
+ autoHide: "leave"
284
+ },
285
+ ...o
286
+ },
287
+ ...s,
288
+ children: e
289
+ }
290
+ ), Ge = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
291
+ <path d="M6 9L12 15L18 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
292
+ </svg>
293
+ `, He = `<svg fill="currentColor" width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
294
+ <path d="M10,18a1,1,0,0,1-.71-.29l-5-5a1,1,0,0,1,1.42-1.42L10,15.59l8.29-8.3a1,1,0,1,1,1.42,1.42l-9,9A1,1,0,0,1,10,18Z"></path>
295
+ </svg>`, Ue = ({ RowComponent: e, options: o, ref: s, ...l }) => {
296
+ const a = $(null), i = G([a, s]), b = De({
297
+ ...o,
298
+ getScrollElement: () => {
299
+ const r = a.current?.getElement()?.firstElementChild;
300
+ return r instanceof HTMLDivElement ? r : null;
301
+ }
302
+ }), c = b.getVirtualItems(), d = b.getTotalSize();
303
+ return /* @__PURE__ */ t(je, { ...l, ref: i, children: /* @__PURE__ */ t(
304
+ Ve.div,
305
+ {
306
+ initial: { opacity: 0 },
307
+ animate: { opacity: 1 },
308
+ style: {
309
+ height: d
310
+ },
311
+ children: /* @__PURE__ */ t(
312
+ "div",
313
+ {
314
+ style: {
315
+ transform: `translateY(${c.at(0)?.start ?? 0}px)`
316
+ },
317
+ children: c.map((r) => /* @__PURE__ */ t("div", { "data-index": r.index, ref: b.measureElement, children: /* @__PURE__ */ t(e, { row: r }) }, r.key))
318
+ }
319
+ )
320
+ }
321
+ ) });
322
+ }, bt = (e) => {
323
+ const {
324
+ placement: o = "bottom-start",
325
+ contentWidth: s,
326
+ visible: l,
327
+ onOpenChange: a,
328
+ dissmiss: i,
329
+ searchable: b,
330
+ value: c,
331
+ optionValue: d,
332
+ optionLabel: r,
333
+ defaultValue: w,
334
+ options: p,
335
+ onChange: v,
336
+ placeholder: S,
337
+ prefix: W,
338
+ suffix: N,
339
+ className: V,
340
+ size: y = "32",
341
+ listProps: C,
342
+ selectedRenderer: E,
343
+ checkedIcon: n,
344
+ ...g
345
+ } = e, [h, k] = I({
346
+ defaultValue: !1,
347
+ value: l
348
+ }), [A, de] = I({
349
+ defaultValue: w,
350
+ value: c
351
+ }), ue = (f, m, x) => {
352
+ !f && !x || (k(f), a?.(f, m, x));
353
+ }, { refs: H, floatingStyles: pe, context: z } = ee({
354
+ open: h,
355
+ onOpenChange: ue,
356
+ placement: o,
357
+ middleware: [
358
+ oe(),
359
+ ne(4),
360
+ se({
361
+ apply({ elements: f }) {
362
+ const { width: m } = f.reference.getBoundingClientRect(), x = s === "fit-parent" ? m : s, O = {
363
+ minWidth: `${x ?? m}px`,
364
+ width: ce(x) ? x : `${x}px`,
365
+ zIndex: L
366
+ };
367
+ Object.assign(f.floating.style, O);
368
+ }
369
+ })
370
+ ],
371
+ whileElementsMounted: te
372
+ }), fe = re(z), be = ie(z, i), he = le(z), { getReferenceProps: ge, getFloatingProps: me } = ae([fe, be, he]), T = X(
373
+ (f) => typeof d == "function" ? d(f) : D(f, d ?? "value"),
374
+ [d]
375
+ ), U = X(
376
+ (f) => typeof r == "function" ? r(f) : D(f, r ?? "label"),
377
+ [r]
378
+ ), ve = (f) => {
379
+ const m = T(f);
380
+ m !== A && (de(m), v?.(m, f), k(!1));
381
+ }, F = j(
382
+ () => p.find((f) => A === T(f)),
383
+ [T, p, A]
384
+ ), we = ({ row: f }) => {
385
+ const m = p.at(f.index);
386
+ if (M(m)) return /* @__PURE__ */ t(xe, {});
387
+ const x = T(m), O = A === x;
388
+ return /* @__PURE__ */ R(
389
+ "div",
390
+ {
391
+ onClick: (Ke) => {
392
+ ve(m);
393
+ },
394
+ "aria-hidden": !0,
395
+ css: [
396
+ {
397
+ padding: 8,
398
+ display: "flex",
399
+ alignItems: "center",
400
+ gap: 8,
401
+ borderRadius: 8,
402
+ cursor: "pointer",
403
+ ":hover": {
404
+ backgroundColor: u.palette.white["1s"]
405
+ }
406
+ },
407
+ O && { backgroundColor: u.palette.black["7s"] }
408
+ ],
409
+ children: [
410
+ /* @__PURE__ */ t("div", { css: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: U(m) }),
411
+ O && (n ?? /* @__PURE__ */ t(P, { size: 16, source: He }))
412
+ ]
413
+ }
414
+ );
415
+ };
416
+ return /* @__PURE__ */ R(ke, { children: [
417
+ /* @__PURE__ */ R(
418
+ "button",
419
+ {
420
+ className: V,
421
+ css: [
422
+ {
423
+ ...u.text.xs,
424
+ height: Number(y),
425
+ display: "inline-flex",
426
+ position: "relative",
427
+ paddingInline: 8,
428
+ borderRadius: 8,
429
+ overflow: "hidden",
430
+ alignItems: "center",
431
+ gap: 8,
432
+ backgroundColor: u.palette.white["1s"],
433
+ color: u.palette.white["6s"],
434
+ "&::after": {
435
+ content: '""',
436
+ position: "absolute",
437
+ inset: 0,
438
+ pointerEvents: "none",
439
+ borderRadius: 8,
440
+ borderWidth: 1,
441
+ borderStyle: "solid",
442
+ borderColor: "transparent"
443
+ }
444
+ },
445
+ h && {
446
+ backgroundColor: u.palette.black["7s"],
447
+ "&::after": {
448
+ content: '""',
449
+ position: "absolute",
450
+ inset: 0,
451
+ pointerEvents: "none",
452
+ borderRadius: 8,
453
+ borderWidth: 1,
454
+ borderStyle: "solid",
455
+ borderColor: u.palette.white["1s"]
456
+ }
457
+ }
458
+ ],
459
+ ...g,
460
+ ...ge(),
461
+ ref: H.setReference,
462
+ children: [
463
+ W,
464
+ /* @__PURE__ */ t("div", { css: { flex: 1, textAlign: "left", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: F ? E?.(F) ?? U(F) : /* @__PURE__ */ t("span", { css: { color: u.palette.white["3s"] }, children: S }) }),
465
+ N ?? /* @__PURE__ */ t(
466
+ P,
467
+ {
468
+ source: Ge,
469
+ css: [{ transition: "transform" }, h && { transform: "rotate(-180deg)" }],
470
+ size: 16
471
+ }
472
+ )
473
+ ]
474
+ }
475
+ ),
476
+ h && /* @__PURE__ */ t(Pe, { root: document.body, children: /* @__PURE__ */ t(
477
+ "div",
478
+ {
479
+ ref: H.setFloating,
480
+ css: { borderRadius: 8, backgroundColor: u.palette.ink["6s"] },
481
+ style: {
482
+ ...pe,
483
+ zIndex: L
484
+ },
485
+ ...me(),
486
+ children: /* @__PURE__ */ R(
487
+ "div",
488
+ {
489
+ css: {
490
+ paddingBlock: 4,
491
+ borderRadius: 8,
492
+ backgroundColor: u.palette.white["1s"],
493
+ color: u.palette.white["6s"],
494
+ ":focus-visible": {
495
+ outlineStyle: "none"
496
+ },
497
+ ...u.text.xs
498
+ },
499
+ children: [
500
+ b && /* @__PURE__ */ t("div", { css: { paddingInline: 8, marginBottom: 8 }, children: /* @__PURE__ */ t(J, { fullWidth: !0, autoFocus: !0 }) }),
501
+ /* @__PURE__ */ t(
502
+ Ue,
503
+ {
504
+ RowComponent: we,
505
+ ...C,
506
+ css: { paddingInline: 4 },
507
+ style: {
508
+ // height: 160,
509
+ ...C?.style
510
+ },
511
+ options: {
512
+ count: p.length,
513
+ estimateSize: () => 32,
514
+ ...C?.options
515
+ }
516
+ }
517
+ )
518
+ ]
519
+ }
520
+ )
521
+ }
522
+ ) })
523
+ ] });
524
+ }, ht = ({ children: e, ...o }) => {
525
+ const s = Be(o);
526
+ return /* @__PURE__ */ R("div", { ...s.getRootProps(), children: [
527
+ e?.(s),
528
+ /* @__PURE__ */ t("input", { ...s.getInputProps() })
529
+ ] });
530
+ };
531
+ export {
532
+ Ge as A,
533
+ je as W,
534
+ lt as a,
535
+ ht as b,
536
+ at as c,
537
+ dt as d,
538
+ ct as e,
539
+ bt as f,
540
+ _e as g,
541
+ ft as h,
542
+ pt as i,
543
+ $e as j,
544
+ ut as k,
545
+ Ue as l
546
+ };