@retailcrm/embed-ui-v1-components 0.9.12 → 0.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/host.cjs +624 -313
- package/dist/host.css +319 -0
- package/dist/host.d.ts +181 -6
- package/dist/host.js +625 -314
- package/dist/remote.cjs +595 -2
- package/dist/remote.d.ts +603 -6
- package/dist/remote.js +596 -3
- package/package.json +5 -3
package/dist/remote.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineRemoteComponent, defineRemoteMethod, nextTick, createRemoteRoot } from "@omnicajs/vue-remote/remote";
|
|
2
|
-
import { openBlock, createElementBlock, createElementVNode, defineComponent, mergeProps, renderSlot, createTextVNode, toDisplayString, createCommentVNode, createVNode, unref, withCtx,
|
|
2
|
+
import { openBlock, createElementBlock, createElementVNode, defineComponent, mergeProps, renderSlot, createTextVNode, toDisplayString, createCommentVNode, createVNode, unref, withCtx, isVNode, Comment, Text, Fragment, getCurrentInstance, ref, computed, watch, h, reactive, inject, useTemplateRef, provide, createBlock, onBeforeMount, onBeforeUnmount, createSlots, onMounted } from "vue";
|
|
3
3
|
import isEqual from "lodash.isequal";
|
|
4
4
|
import { preview } from "@retailcrm/image-preview";
|
|
5
5
|
import { ru, es, enGB } from "date-fns/locale";
|
|
@@ -161,7 +161,7 @@ const _hoisted_5 = {
|
|
|
161
161
|
class: "ui-v1-field__addon"
|
|
162
162
|
};
|
|
163
163
|
const _hoisted_6 = { class: "ui-v1-field__control" };
|
|
164
|
-
const _sfc_main$
|
|
164
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
165
165
|
...{
|
|
166
166
|
inheritAttrs: false
|
|
167
167
|
},
|
|
@@ -413,6 +413,577 @@ const UiSwitch = defineRemoteComponent(
|
|
|
413
413
|
UiSwitchType,
|
|
414
414
|
["click", "focus", "blur"]
|
|
415
415
|
);
|
|
416
|
+
var ALIGN = /* @__PURE__ */ ((ALIGN2) => {
|
|
417
|
+
ALIGN2["LEFT"] = "left";
|
|
418
|
+
ALIGN2["CENTER"] = "center";
|
|
419
|
+
ALIGN2["RIGHT"] = "right";
|
|
420
|
+
return ALIGN2;
|
|
421
|
+
})(ALIGN || {});
|
|
422
|
+
var VALIGN = /* @__PURE__ */ ((VALIGN2) => {
|
|
423
|
+
VALIGN2["TOP"] = "top";
|
|
424
|
+
VALIGN2["MIDDLE"] = "middle";
|
|
425
|
+
VALIGN2["BOTTOM"] = "bottom";
|
|
426
|
+
return VALIGN2;
|
|
427
|
+
})(VALIGN || {});
|
|
428
|
+
var DIRECTION = /* @__PURE__ */ ((DIRECTION2) => {
|
|
429
|
+
DIRECTION2["ASC"] = "asc";
|
|
430
|
+
DIRECTION2["DESC"] = "desc";
|
|
431
|
+
return DIRECTION2;
|
|
432
|
+
})(DIRECTION || {});
|
|
433
|
+
const byRowKey = (key) => {
|
|
434
|
+
return (row) => row[key];
|
|
435
|
+
};
|
|
436
|
+
const asRowClass = (value) => value;
|
|
437
|
+
const asRowAttrs = (value) => value;
|
|
438
|
+
const _sfc_main$5 = defineComponent({
|
|
439
|
+
name: "UiTableColumn",
|
|
440
|
+
props: {
|
|
441
|
+
label: {
|
|
442
|
+
type: String,
|
|
443
|
+
default: ""
|
|
444
|
+
},
|
|
445
|
+
width: {
|
|
446
|
+
type: [String, Number],
|
|
447
|
+
default: void 0
|
|
448
|
+
},
|
|
449
|
+
minWidth: {
|
|
450
|
+
type: [String, Number],
|
|
451
|
+
default: void 0
|
|
452
|
+
},
|
|
453
|
+
maxWidth: {
|
|
454
|
+
type: [String, Number],
|
|
455
|
+
default: void 0
|
|
456
|
+
},
|
|
457
|
+
align: {
|
|
458
|
+
type: String,
|
|
459
|
+
default: ALIGN.LEFT,
|
|
460
|
+
validator: (align) => Object.values(ALIGN).includes(align)
|
|
461
|
+
},
|
|
462
|
+
valign: {
|
|
463
|
+
type: String,
|
|
464
|
+
default: VALIGN.MIDDLE,
|
|
465
|
+
validator: (valign) => Object.values(VALIGN).includes(valign)
|
|
466
|
+
},
|
|
467
|
+
trim: {
|
|
468
|
+
type: Boolean,
|
|
469
|
+
default: false
|
|
470
|
+
},
|
|
471
|
+
colspan: {
|
|
472
|
+
type: Function,
|
|
473
|
+
default: void 0
|
|
474
|
+
},
|
|
475
|
+
rowspan: {
|
|
476
|
+
type: Function,
|
|
477
|
+
default: void 0
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
setup() {
|
|
481
|
+
return () => null;
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
const UiTableRootType = "UiTableRoot";
|
|
485
|
+
const UiTableRoot = defineRemoteComponent(UiTableRootType);
|
|
486
|
+
const UiTableSectionType = "UiTableSection";
|
|
487
|
+
const UiTableSection = defineRemoteComponent(UiTableSectionType);
|
|
488
|
+
const UiTableRowType = "UiTableRow";
|
|
489
|
+
const UiTableRow = defineRemoteComponent(
|
|
490
|
+
UiTableRowType,
|
|
491
|
+
["click"]
|
|
492
|
+
);
|
|
493
|
+
const UiTableColType = "UiTableCol";
|
|
494
|
+
const UiTableCol = defineRemoteComponent(UiTableColType);
|
|
495
|
+
const UiTableFooterSectionType = "UiTableFooterSection";
|
|
496
|
+
const UiTableFooterSection = defineRemoteComponent(UiTableFooterSectionType);
|
|
497
|
+
const UiTableFooterButtonType = "UiTableFooterButton";
|
|
498
|
+
const UiTableFooterButton = defineRemoteComponent(
|
|
499
|
+
UiTableFooterButtonType,
|
|
500
|
+
["click"]
|
|
501
|
+
);
|
|
502
|
+
const UiTableHeadCellType = "UiTableHeadCell";
|
|
503
|
+
const UiTableHeadCell = defineRemoteComponent(UiTableHeadCellType);
|
|
504
|
+
const UiTableBodyCellType = "UiTableBodyCell";
|
|
505
|
+
const UiTableBodyCell = defineRemoteComponent(UiTableBodyCellType);
|
|
506
|
+
const UiTableSorterType = "UiTableSorter";
|
|
507
|
+
const UiTableSorter = defineRemoteComponent(
|
|
508
|
+
UiTableSorterType,
|
|
509
|
+
["click"]
|
|
510
|
+
);
|
|
511
|
+
const isNamedComponent = (node, name) => {
|
|
512
|
+
if (typeof node.type !== "object" || node.type === null) {
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
return "name" in node.type && node.type.name === name;
|
|
516
|
+
};
|
|
517
|
+
const isTableColumnVNode = (node) => {
|
|
518
|
+
return node.type === _sfc_main$5 || isNamedComponent(node, "UiTableColumn");
|
|
519
|
+
};
|
|
520
|
+
const isWhitespaceText = (value) => value.trim().length === 0;
|
|
521
|
+
const normalizeNodes = (children) => {
|
|
522
|
+
const normalized = [];
|
|
523
|
+
children.forEach((child) => {
|
|
524
|
+
if (Array.isArray(child)) {
|
|
525
|
+
normalized.push(...normalizeNodes(child));
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
if (typeof child === "string") {
|
|
529
|
+
if (!isWhitespaceText(child)) {
|
|
530
|
+
normalized.push(child);
|
|
531
|
+
}
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
if (typeof child === "number") {
|
|
535
|
+
normalized.push(child);
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (!isVNode(child)) {
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
if (child.type === Comment) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
if (child.type === Text) {
|
|
545
|
+
const text = typeof child.children === "string" ? child.children : "";
|
|
546
|
+
if (!isWhitespaceText(text)) {
|
|
547
|
+
normalized.push(text);
|
|
548
|
+
}
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
if (child.type === Fragment && Array.isArray(child.children)) {
|
|
552
|
+
normalized.push(...normalizeNodes(child.children));
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
normalized.push(child);
|
|
556
|
+
});
|
|
557
|
+
return normalized;
|
|
558
|
+
};
|
|
559
|
+
const normalizeBoolean = (value) => value === "" || value === true;
|
|
560
|
+
const normalizeString = (value) => typeof value === "string" ? value : "";
|
|
561
|
+
const normalizeAlign = (value) => {
|
|
562
|
+
return Object.values(ALIGN).includes(value) ? value : ALIGN.LEFT;
|
|
563
|
+
};
|
|
564
|
+
const normalizeValign = (value) => {
|
|
565
|
+
return Object.values(VALIGN).includes(value) ? value : VALIGN.MIDDLE;
|
|
566
|
+
};
|
|
567
|
+
const normalizeSlotRecord = (node) => {
|
|
568
|
+
const children = node.children;
|
|
569
|
+
if (!children || Array.isArray(children) || typeof children === "string") {
|
|
570
|
+
return {};
|
|
571
|
+
}
|
|
572
|
+
const slots = children;
|
|
573
|
+
return {
|
|
574
|
+
defaultSlot: slots.default,
|
|
575
|
+
cellSlot: slots.cell,
|
|
576
|
+
labelSlot: slots.label
|
|
577
|
+
};
|
|
578
|
+
};
|
|
579
|
+
const resolveFunction = (value) => {
|
|
580
|
+
if (typeof value === "function") {
|
|
581
|
+
return value;
|
|
582
|
+
}
|
|
583
|
+
return () => void 0;
|
|
584
|
+
};
|
|
585
|
+
const collectTableColumns = (children) => {
|
|
586
|
+
return normalizeNodes(children).filter((node) => isVNode(node)).filter(isTableColumnVNode).map((node, index) => {
|
|
587
|
+
const props = node.props ?? {};
|
|
588
|
+
const slots = normalizeSlotRecord(node);
|
|
589
|
+
return {
|
|
590
|
+
id: String(node.key ?? `ui-v1-table-column-${index}`),
|
|
591
|
+
label: normalizeString(props.label),
|
|
592
|
+
width: props.width,
|
|
593
|
+
minWidth: props.minWidth ?? props["min-width"],
|
|
594
|
+
maxWidth: props.maxWidth ?? props["max-width"],
|
|
595
|
+
align: normalizeAlign(props.align),
|
|
596
|
+
valign: normalizeValign(props.valign),
|
|
597
|
+
trim: normalizeBoolean(props.trim),
|
|
598
|
+
getColspan: resolveFunction(props.colspan),
|
|
599
|
+
getRowspan: resolveFunction(props.rowspan),
|
|
600
|
+
cellSlot: slots.cellSlot,
|
|
601
|
+
defaultSlot: slots.defaultSlot,
|
|
602
|
+
labelSlot: slots.labelSlot
|
|
603
|
+
};
|
|
604
|
+
});
|
|
605
|
+
};
|
|
606
|
+
const normalizeSpan = (value) => {
|
|
607
|
+
if (typeof value === "undefined") {
|
|
608
|
+
return void 0;
|
|
609
|
+
}
|
|
610
|
+
const normalized = Math.trunc(Number(value));
|
|
611
|
+
if (!Number.isFinite(normalized) || normalized < 1) {
|
|
612
|
+
return void 0;
|
|
613
|
+
}
|
|
614
|
+
return normalized;
|
|
615
|
+
};
|
|
616
|
+
const renderLabel = (column) => column.labelSlot?.({ column }) ?? [column.label];
|
|
617
|
+
const renderCell = (column, props) => column.cellSlot?.(props) ?? column.defaultSlot?.(props) ?? [];
|
|
618
|
+
const buildRenderedRows = (options) => {
|
|
619
|
+
const activeRowspans = Array.from({ length: options.columns.length }, () => 0);
|
|
620
|
+
return options.rows.map((row, index) => {
|
|
621
|
+
const key = options.resolveKey(row, index);
|
|
622
|
+
const expanded = options.expandedKeys.has(key);
|
|
623
|
+
const toggle = () => options.toggle(key);
|
|
624
|
+
const attrs = options.resolveRowAttrs(row, index);
|
|
625
|
+
const cells = [];
|
|
626
|
+
let pendingColspan = 0;
|
|
627
|
+
options.columns.forEach((column, columnIndex) => {
|
|
628
|
+
if (pendingColspan > 0) {
|
|
629
|
+
pendingColspan -= 1;
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
if (activeRowspans[columnIndex] > 0) {
|
|
633
|
+
activeRowspans[columnIndex] -= 1;
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
const slotProps = {
|
|
637
|
+
row,
|
|
638
|
+
index,
|
|
639
|
+
key,
|
|
640
|
+
expanded,
|
|
641
|
+
toggle,
|
|
642
|
+
column
|
|
643
|
+
};
|
|
644
|
+
const colspan = normalizeSpan(column.getColspan(row, index));
|
|
645
|
+
const rowspan = normalizeSpan(column.getRowspan(row, index));
|
|
646
|
+
const resolvedColspan = colspan && colspan > 1 ? colspan : void 0;
|
|
647
|
+
const resolvedRowspan = rowspan && rowspan > 1 ? rowspan : void 0;
|
|
648
|
+
if (resolvedColspan) {
|
|
649
|
+
pendingColspan = resolvedColspan - 1;
|
|
650
|
+
}
|
|
651
|
+
if (resolvedRowspan) {
|
|
652
|
+
for (let spanIndex = 0; spanIndex < (resolvedColspan ?? 1); spanIndex++) {
|
|
653
|
+
activeRowspans[columnIndex + spanIndex] = Math.max(
|
|
654
|
+
activeRowspans[columnIndex + spanIndex] ?? 0,
|
|
655
|
+
resolvedRowspan - 1
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
cells.push({
|
|
660
|
+
column,
|
|
661
|
+
colspan: resolvedColspan,
|
|
662
|
+
rowspan: resolvedRowspan,
|
|
663
|
+
slotProps
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
return {
|
|
667
|
+
row,
|
|
668
|
+
index,
|
|
669
|
+
key,
|
|
670
|
+
attrs,
|
|
671
|
+
expanded,
|
|
672
|
+
toggle,
|
|
673
|
+
cells,
|
|
674
|
+
className: [
|
|
675
|
+
options.resolveRowClass(row, index),
|
|
676
|
+
attrs.class,
|
|
677
|
+
options.extraClass
|
|
678
|
+
]
|
|
679
|
+
};
|
|
680
|
+
});
|
|
681
|
+
};
|
|
682
|
+
const isCellVNode = (node) => {
|
|
683
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
684
|
+
return false;
|
|
685
|
+
}
|
|
686
|
+
return node.type === UiTableBodyCell || node.type === UiTableHeadCell || isNamedComponent(node, "UiTableBodyCell") || isNamedComponent(node, "UiTableHeadCell") || node.type === "td" || node.type === "th";
|
|
687
|
+
};
|
|
688
|
+
const slotNeedsBodyCellWrapper = (children) => {
|
|
689
|
+
const nodes = normalizeNodes(children);
|
|
690
|
+
if (nodes.length === 0) {
|
|
691
|
+
return true;
|
|
692
|
+
}
|
|
693
|
+
return !nodes.every(isCellVNode);
|
|
694
|
+
};
|
|
695
|
+
const renderGroupHead = (slot, props) => {
|
|
696
|
+
return slot?.(props) ?? [String(props.group.key)];
|
|
697
|
+
};
|
|
698
|
+
const renderExpand = (slot, props) => slot?.(props) ?? [];
|
|
699
|
+
const getRowClass = (rowClass, row, index) => {
|
|
700
|
+
if (typeof rowClass === "function") {
|
|
701
|
+
return rowClass(row, index);
|
|
702
|
+
}
|
|
703
|
+
return rowClass;
|
|
704
|
+
};
|
|
705
|
+
const getRowAttrs = (rowAttrs, row, index) => rowAttrs?.(row, index) ?? {};
|
|
706
|
+
const resolveRowKey = (rowKey, row, index) => {
|
|
707
|
+
if (typeof rowKey === "function") {
|
|
708
|
+
return rowKey(row, index);
|
|
709
|
+
}
|
|
710
|
+
if (typeof rowKey !== "undefined" && typeof row === "object" && row !== null && rowKey in row) {
|
|
711
|
+
const value = row[rowKey];
|
|
712
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
713
|
+
return value;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return index;
|
|
717
|
+
};
|
|
718
|
+
const withoutClass = (attrs) => {
|
|
719
|
+
const next = { ...attrs };
|
|
720
|
+
delete next.class;
|
|
721
|
+
return next;
|
|
722
|
+
};
|
|
723
|
+
const _sfc_main$4 = defineComponent({
|
|
724
|
+
name: "UiTable",
|
|
725
|
+
inheritAttrs: false,
|
|
726
|
+
props: {
|
|
727
|
+
rows: {
|
|
728
|
+
type: Array,
|
|
729
|
+
default: () => []
|
|
730
|
+
},
|
|
731
|
+
rowKey: {
|
|
732
|
+
type: [String, Number, Function],
|
|
733
|
+
default: void 0
|
|
734
|
+
},
|
|
735
|
+
headless: {
|
|
736
|
+
type: Boolean,
|
|
737
|
+
default: false
|
|
738
|
+
},
|
|
739
|
+
bordered: {
|
|
740
|
+
type: Boolean,
|
|
741
|
+
default: false
|
|
742
|
+
},
|
|
743
|
+
fixed: {
|
|
744
|
+
type: Boolean,
|
|
745
|
+
default: false
|
|
746
|
+
},
|
|
747
|
+
rowClass: {
|
|
748
|
+
type: [String, Array, Object, Function],
|
|
749
|
+
default: void 0
|
|
750
|
+
},
|
|
751
|
+
rowAttrs: {
|
|
752
|
+
type: Function,
|
|
753
|
+
default: void 0
|
|
754
|
+
},
|
|
755
|
+
groupBy: {
|
|
756
|
+
type: Function,
|
|
757
|
+
default: void 0
|
|
758
|
+
},
|
|
759
|
+
groupHeadClass: {
|
|
760
|
+
type: [String, Array, Object],
|
|
761
|
+
default: void 0
|
|
762
|
+
},
|
|
763
|
+
groupBodyClass: {
|
|
764
|
+
type: [String, Array, Object],
|
|
765
|
+
default: void 0
|
|
766
|
+
}
|
|
767
|
+
},
|
|
768
|
+
emits: {
|
|
769
|
+
"row:click": (payload, event) => {
|
|
770
|
+
return true;
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
setup(props, { attrs, emit, expose, slots }) {
|
|
774
|
+
const instance = getCurrentInstance();
|
|
775
|
+
const expandedKeys = ref([]);
|
|
776
|
+
const isInteractive = computed(() => Boolean(
|
|
777
|
+
instance?.vnode.props?.onRowClick || instance?.vnode.props?.["onRow:click"]
|
|
778
|
+
));
|
|
779
|
+
const toggleExpanded = (key) => {
|
|
780
|
+
expandedKeys.value = expandedKeys.value.includes(key) ? expandedKeys.value.filter((item) => item !== key) : [...expandedKeys.value, key];
|
|
781
|
+
};
|
|
782
|
+
const resetExpanded = () => {
|
|
783
|
+
expandedKeys.value = [];
|
|
784
|
+
};
|
|
785
|
+
const expand = (key) => {
|
|
786
|
+
if (!expandedKeys.value.includes(key)) {
|
|
787
|
+
expandedKeys.value = [...expandedKeys.value, key];
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
const collapse = (key) => {
|
|
791
|
+
expandedKeys.value = expandedKeys.value.filter((item) => item !== key);
|
|
792
|
+
};
|
|
793
|
+
expose({
|
|
794
|
+
resetExpanded,
|
|
795
|
+
expand,
|
|
796
|
+
collapse,
|
|
797
|
+
toggle: toggleExpanded
|
|
798
|
+
});
|
|
799
|
+
watch([() => props.rows, () => props.rowKey], () => {
|
|
800
|
+
const availableKeys = new Set(
|
|
801
|
+
props.rows.map((row, index) => resolveRowKey(props.rowKey, row, index))
|
|
802
|
+
);
|
|
803
|
+
const next = expandedKeys.value.filter((key) => availableKeys.has(key));
|
|
804
|
+
if (next.length !== expandedKeys.value.length) {
|
|
805
|
+
expandedKeys.value = next;
|
|
806
|
+
}
|
|
807
|
+
}, { deep: false });
|
|
808
|
+
const resolveColumns = () => collectTableColumns(slots.default?.() ?? []);
|
|
809
|
+
const resolveGroups = () => {
|
|
810
|
+
return props.groupBy ? props.groupBy(props.rows) : [];
|
|
811
|
+
};
|
|
812
|
+
const resolveFooterData = (currentColumns, currentGroups) => ({
|
|
813
|
+
columnsCount: currentColumns.length,
|
|
814
|
+
rowsCount: props.rows.length,
|
|
815
|
+
groupsCount: currentGroups.length,
|
|
816
|
+
groups: currentGroups
|
|
817
|
+
});
|
|
818
|
+
const hasStructuredFooter = () => {
|
|
819
|
+
return [
|
|
820
|
+
"footer-summary",
|
|
821
|
+
"footer-page-size",
|
|
822
|
+
"footer-export",
|
|
823
|
+
"footer-pagination"
|
|
824
|
+
].some((name) => Boolean(slots[name]));
|
|
825
|
+
};
|
|
826
|
+
const hasFooter = () => Boolean(slots.footer) || hasStructuredFooter();
|
|
827
|
+
const resolveColumnsCount = (currentColumns) => {
|
|
828
|
+
return Math.max(currentColumns.length, 1);
|
|
829
|
+
};
|
|
830
|
+
const buildPlainRows = (currentColumns) => buildRenderedRows({
|
|
831
|
+
columns: currentColumns,
|
|
832
|
+
rows: props.rows,
|
|
833
|
+
expandedKeys: new Set(expandedKeys.value),
|
|
834
|
+
resolveKey: (row, index) => resolveRowKey(props.rowKey, row, index),
|
|
835
|
+
resolveRowAttrs: (row, index) => getRowAttrs(props.rowAttrs, row, index),
|
|
836
|
+
resolveRowClass: (row, index) => getRowClass(props.rowClass, row, index),
|
|
837
|
+
toggle: toggleExpanded
|
|
838
|
+
});
|
|
839
|
+
const buildGroupedRows = (currentColumns, currentGroups) => currentGroups.map((group) => ({
|
|
840
|
+
group,
|
|
841
|
+
rows: buildRenderedRows({
|
|
842
|
+
columns: currentColumns,
|
|
843
|
+
rows: group.rows,
|
|
844
|
+
expandedKeys: new Set(expandedKeys.value),
|
|
845
|
+
extraClass: props.groupBodyClass,
|
|
846
|
+
resolveKey: (row, index) => resolveRowKey(props.rowKey, row, index),
|
|
847
|
+
resolveRowAttrs: (row, index) => getRowAttrs(props.rowAttrs, row, index),
|
|
848
|
+
resolveRowClass: (row, index) => getRowClass(props.rowClass, row, index),
|
|
849
|
+
toggle: toggleExpanded
|
|
850
|
+
})
|
|
851
|
+
}));
|
|
852
|
+
const emitRowClick = (payload, event) => {
|
|
853
|
+
emit("row:click", payload, event);
|
|
854
|
+
};
|
|
855
|
+
const renderBodyRow = (row, columnsCount, suffix = "row") => {
|
|
856
|
+
const rowKey = `${String(row.key)}:${suffix}`;
|
|
857
|
+
return [
|
|
858
|
+
h(UiTableRow, {
|
|
859
|
+
key: rowKey,
|
|
860
|
+
interactive: isInteractive.value,
|
|
861
|
+
expanded: row.expanded,
|
|
862
|
+
...withoutClass(row.attrs),
|
|
863
|
+
class: row.className,
|
|
864
|
+
onClick: (event) => emitRowClick({
|
|
865
|
+
row: row.row,
|
|
866
|
+
index: row.index,
|
|
867
|
+
key: row.key,
|
|
868
|
+
expanded: row.expanded,
|
|
869
|
+
toggle: row.toggle
|
|
870
|
+
}, event)
|
|
871
|
+
}, () => row.cells.map((cell, cellIndex) => h(UiTableBodyCell, {
|
|
872
|
+
key: `${rowKey}:cell:${cell.column.id}:${cellIndex}`,
|
|
873
|
+
align: cell.column.align,
|
|
874
|
+
valign: cell.column.valign,
|
|
875
|
+
colspan: cell.colspan,
|
|
876
|
+
rowspan: cell.rowspan,
|
|
877
|
+
trim: cell.column.trim
|
|
878
|
+
}, () => renderCell(cell.column, cell.slotProps)))),
|
|
879
|
+
slots.expand && row.expanded ? h(UiTableRow, {
|
|
880
|
+
key: `${rowKey}:expand`,
|
|
881
|
+
expanded: true
|
|
882
|
+
}, () => h(UiTableBodyCell, {
|
|
883
|
+
colspan: columnsCount
|
|
884
|
+
}, () => renderExpand(slots.expand, {
|
|
885
|
+
row: row.row,
|
|
886
|
+
index: row.index,
|
|
887
|
+
key: row.key
|
|
888
|
+
}))) : null
|
|
889
|
+
];
|
|
890
|
+
};
|
|
891
|
+
const renderGroupHeadRow = (group, index, columnsCount) => {
|
|
892
|
+
const content = renderGroupHead(slots["group-head"], {
|
|
893
|
+
group,
|
|
894
|
+
index
|
|
895
|
+
});
|
|
896
|
+
return h(UiTableRow, {
|
|
897
|
+
key: `${String(group.key)}:group-head`,
|
|
898
|
+
class: props.groupHeadClass
|
|
899
|
+
}, () => {
|
|
900
|
+
if (slotNeedsBodyCellWrapper(content)) {
|
|
901
|
+
return h(UiTableBodyCell, {
|
|
902
|
+
colspan: columnsCount,
|
|
903
|
+
theme: "group"
|
|
904
|
+
}, () => h("div", { class: "ui-v1-table__group-head" }, content));
|
|
905
|
+
}
|
|
906
|
+
return content;
|
|
907
|
+
});
|
|
908
|
+
};
|
|
909
|
+
const renderEmptyRow = (columnsCount) => h(UiTableRow, { key: "empty" }, () => h(UiTableBodyCell, {
|
|
910
|
+
colspan: columnsCount
|
|
911
|
+
}, () => h("div", { class: "ui-v1-table__empty" }, slots.empty?.() ?? [])));
|
|
912
|
+
const renderFooter = (footerData, columnsCount) => {
|
|
913
|
+
if (!hasFooter()) {
|
|
914
|
+
return null;
|
|
915
|
+
}
|
|
916
|
+
if (hasStructuredFooter()) {
|
|
917
|
+
const summary = slots["footer-summary"]?.(footerData);
|
|
918
|
+
const pageSize = slots["footer-page-size"]?.(footerData);
|
|
919
|
+
const exportControl = slots["footer-export"]?.(footerData);
|
|
920
|
+
const pagination = slots["footer-pagination"]?.(footerData);
|
|
921
|
+
return h(UiTableSection, { kind: "foot", key: "footer" }, () => h(UiTableRow, () => h(UiTableBodyCell, {
|
|
922
|
+
colspan: columnsCount,
|
|
923
|
+
class: "ui-v1-table__footer-cell"
|
|
924
|
+
}, () => h("div", { class: "ui-v1-table__footer" }, [
|
|
925
|
+
summary ? h("div", { class: "ui-v1-table__footer-meta" }, [summary]) : null,
|
|
926
|
+
pageSize || exportControl || pagination ? h("div", { class: "ui-v1-table__footer-controls" }, [
|
|
927
|
+
pageSize || exportControl ? h("div", { class: "ui-v1-table__footer-main" }, [
|
|
928
|
+
pageSize,
|
|
929
|
+
exportControl
|
|
930
|
+
]) : null,
|
|
931
|
+
pagination ? h("div", { class: "ui-v1-table__footer-side" }, [pagination]) : null
|
|
932
|
+
]) : null
|
|
933
|
+
]))));
|
|
934
|
+
}
|
|
935
|
+
const content = slots.footer?.(footerData) ?? [];
|
|
936
|
+
return h(UiTableSection, { kind: "foot", key: "footer" }, () => h(UiTableRow, () => {
|
|
937
|
+
if (slotNeedsBodyCellWrapper(content)) {
|
|
938
|
+
return h(UiTableBodyCell, {
|
|
939
|
+
colspan: columnsCount
|
|
940
|
+
}, () => content);
|
|
941
|
+
}
|
|
942
|
+
return content;
|
|
943
|
+
}));
|
|
944
|
+
};
|
|
945
|
+
return () => h(UiTableRoot, {
|
|
946
|
+
...attrs,
|
|
947
|
+
bordered: props.bordered,
|
|
948
|
+
fixed: props.fixed
|
|
949
|
+
}, () => [
|
|
950
|
+
(() => {
|
|
951
|
+
const currentColumns = resolveColumns();
|
|
952
|
+
const currentColumnsCount = resolveColumnsCount(currentColumns);
|
|
953
|
+
const currentGroups = resolveGroups();
|
|
954
|
+
const currentFooterData = resolveFooterData(currentColumns, currentGroups);
|
|
955
|
+
const currentPlainRows = buildPlainRows(currentColumns);
|
|
956
|
+
const currentGroupedRows = buildGroupedRows(currentColumns, currentGroups);
|
|
957
|
+
return [
|
|
958
|
+
currentColumns.length > 0 ? h("colgroup", { key: "colgroup" }, currentColumns.map((column) => h(UiTableCol, {
|
|
959
|
+
key: `col:${column.id}`,
|
|
960
|
+
width: column.width,
|
|
961
|
+
minWidth: column.minWidth,
|
|
962
|
+
maxWidth: column.maxWidth
|
|
963
|
+
}))) : null,
|
|
964
|
+
!props.headless && currentColumns.length > 0 ? h(UiTableSection, { key: "head", kind: "head" }, () => h(UiTableRow, () => currentColumns.map((column) => h(UiTableHeadCell, {
|
|
965
|
+
key: `head:${column.id}`,
|
|
966
|
+
align: column.align,
|
|
967
|
+
trim: column.trim
|
|
968
|
+
}, () => renderLabel(column))))) : null,
|
|
969
|
+
h(UiTableSection, { key: "body", kind: "body" }, () => {
|
|
970
|
+
if (props.rows.length === 0) {
|
|
971
|
+
return renderEmptyRow(currentColumnsCount);
|
|
972
|
+
}
|
|
973
|
+
if (props.groupBy) {
|
|
974
|
+
return currentGroupedRows.flatMap(({ group, rows }, index) => [
|
|
975
|
+
renderGroupHeadRow(group, index, currentColumnsCount),
|
|
976
|
+
...rows.flatMap((row) => renderBodyRow(row, currentColumnsCount, `${String(group.key)}:row`))
|
|
977
|
+
]);
|
|
978
|
+
}
|
|
979
|
+
return currentPlainRows.flatMap((row) => renderBodyRow(row, currentColumnsCount));
|
|
980
|
+
}),
|
|
981
|
+
renderFooter(currentFooterData, currentColumnsCount)
|
|
982
|
+
];
|
|
983
|
+
})()
|
|
984
|
+
]);
|
|
985
|
+
}
|
|
986
|
+
});
|
|
416
987
|
const UiTagType = "UiTag";
|
|
417
988
|
const UiTag = defineRemoteComponent(
|
|
418
989
|
UiTagType,
|
|
@@ -1536,6 +2107,15 @@ const createEndpointRoot = async (channel) => {
|
|
|
1536
2107
|
"UiSwitch",
|
|
1537
2108
|
"UiSelectPopper",
|
|
1538
2109
|
"UiSelectTrigger",
|
|
2110
|
+
"UiTableBodyCell",
|
|
2111
|
+
"UiTableCol",
|
|
2112
|
+
"UiTableFooterButton",
|
|
2113
|
+
"UiTableFooterSection",
|
|
2114
|
+
"UiTableHeadCell",
|
|
2115
|
+
"UiTableRoot",
|
|
2116
|
+
"UiTableRow",
|
|
2117
|
+
"UiTableSection",
|
|
2118
|
+
"UiTableSorter",
|
|
1539
2119
|
"UiTag",
|
|
1540
2120
|
"UiTextbox",
|
|
1541
2121
|
"UiTimePicker",
|
|
@@ -1599,6 +2179,8 @@ function detectLocale() {
|
|
|
1599
2179
|
return "en-GB";
|
|
1600
2180
|
}
|
|
1601
2181
|
export {
|
|
2182
|
+
ALIGN,
|
|
2183
|
+
DIRECTION,
|
|
1602
2184
|
ImageWorkersKey,
|
|
1603
2185
|
UiAddButton,
|
|
1604
2186
|
UiAddButtonType,
|
|
@@ -1628,7 +2210,7 @@ export {
|
|
|
1628
2210
|
UiDateType,
|
|
1629
2211
|
UiError,
|
|
1630
2212
|
UiErrorType,
|
|
1631
|
-
_sfc_main$
|
|
2213
|
+
_sfc_main$6 as UiField,
|
|
1632
2214
|
UiInfobox,
|
|
1633
2215
|
UiInfoboxType,
|
|
1634
2216
|
UiLink,
|
|
@@ -1664,6 +2246,13 @@ export {
|
|
|
1664
2246
|
UiSliderType,
|
|
1665
2247
|
UiSwitch,
|
|
1666
2248
|
UiSwitchType,
|
|
2249
|
+
_sfc_main$4 as UiTable,
|
|
2250
|
+
UiTableBodyCell,
|
|
2251
|
+
_sfc_main$5 as UiTableColumn,
|
|
2252
|
+
UiTableFooterButton,
|
|
2253
|
+
UiTableFooterSection,
|
|
2254
|
+
UiTableHeadCell,
|
|
2255
|
+
UiTableSorter,
|
|
1667
2256
|
UiTag,
|
|
1668
2257
|
UiTagType,
|
|
1669
2258
|
UiTextbox,
|
|
@@ -1680,6 +2269,10 @@ export {
|
|
|
1680
2269
|
UiTransitionType,
|
|
1681
2270
|
UiYandexMap,
|
|
1682
2271
|
UiYandexMapType,
|
|
2272
|
+
VALIGN,
|
|
2273
|
+
asRowAttrs,
|
|
2274
|
+
asRowClass,
|
|
2275
|
+
byRowKey,
|
|
1683
2276
|
createEndpointRoot,
|
|
1684
2277
|
formatDate,
|
|
1685
2278
|
formatDateTime,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retailcrm/embed-ui-v1-components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.13",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "RetailDriverLLC <integration@retailcrm.ru>",
|
|
7
7
|
"repository": "git@github.com:retailcrm/embed-ui.git",
|
|
@@ -48,13 +48,14 @@
|
|
|
48
48
|
"build:host": "vite build -c ./vite.config.host.ts",
|
|
49
49
|
"build:remote": "vite build -c ./vite.config.remote.ts && sh -c 'cp dist/remote/* dist/ && rm -rf dist/remote'",
|
|
50
50
|
"storybook:build": "storybook build -c storybook -o ./storybook/dist",
|
|
51
|
-
"storybook:serve": "storybook dev -c storybook -p 6006 --no-open"
|
|
51
|
+
"storybook:serve": "storybook dev -c storybook -p 6006 --no-open",
|
|
52
|
+
"storybook:shot": "tsx ./storybook/scripts/shot.ts"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
55
|
"vue": "^3.5"
|
|
55
56
|
},
|
|
56
57
|
"dependencies": {
|
|
57
|
-
"@omnicajs/vue-remote": "^0.2.
|
|
58
|
+
"@omnicajs/vue-remote": "^0.2.19",
|
|
58
59
|
"@remote-ui/rpc": "^1.4.7",
|
|
59
60
|
"@retailcrm/image-preview": "^1.0.2",
|
|
60
61
|
"date-fns": "^4.1.0",
|
|
@@ -76,6 +77,7 @@
|
|
|
76
77
|
"@yandex/ymaps3-types": "^0.0.21",
|
|
77
78
|
"highlight.js": "^11.11.1",
|
|
78
79
|
"less": "^4.4.2",
|
|
80
|
+
"playwright": "1.58.2",
|
|
79
81
|
"react": "^18.3.1",
|
|
80
82
|
"react-dom": "^18.3.1",
|
|
81
83
|
"remark-gfm": "^4.0.0",
|